IOrganizationService.Disassociate 메서드
Deletes a link between records.
네임스페이스: Microsoft.Xrm.Sdk
어셈블리: Microsoft.Xrm.Sdk(Microsoft.Xrm.Sdk.dll에 있음)
구문
‘선언
<FaultContractAttribute(GetType(OrganizationServiceFault))> _
<OperationContractAttribute> _
Sub Disassociate ( _
entityName As String, _
entityId As Guid, _
relationship As Relationship, _
relatedEntities As EntityReferenceCollection _
)
[FaultContractAttribute(typeof(OrganizationServiceFault))]
[OperationContractAttribute]
void Disassociate (
string entityName,
Guid entityId,
Relationship relationship,
EntityReferenceCollection relatedEntities
)
매개 변수
- entityName
Type: 문자열. The logical name of the entity that is specified in the entityId parameter.
- entityId
Type: Guid. The ID of the record from which the related records are disassociated.
- relationship
Type: Relationship. The name of the relationship to be used to remove the link.
- relatedEntities
Type: EntityReferenceCollection. A collection of entity references (references to records) to be disassociated.
예제
The following example demonstrates how to use the Disassociate method to remove an association or link between records (early bound).
// Associate the accounts to the contact record.
// Create a collection of the entities that will be
// associated to the contact.
EntityReferenceCollection relatedEntities = new EntityReferenceCollection();
relatedEntities.Add(new EntityReference(Account.EntityLogicalName, _account1Id));
relatedEntities.Add(new EntityReference(Account.EntityLogicalName, _account2Id));
relatedEntities.Add(new EntityReference(Account.EntityLogicalName, _account3Id));
// Create an object that defines the relationship between the contact and account.
Relationship relationship = new Relationship("account_primary_contact");
//Associate the contact with the 3 accounts.
_service.Associate(Contact.EntityLogicalName, _contactId, relationship,
relatedEntities);
Console.WriteLine("The entities have been associated.");
//Disassociate the records.
_service.Disassociate(Contact.EntityLogicalName, _contactId, relationship,
relatedEntities);
The following example demonstrates how to use the Disassociate method to remove an association or link between records (late bound).
// The account ID would typically be passed in as an argument or determined by a query.
// The contact ID would typically be passed in as an argument or determined by a query.
// Associate the accounts to the contact record.
//Create a collection of the entity ids that will be associated to the contact.
EntityReferenceCollection relatedEntities = new EntityReferenceCollection();
relatedEntities.Add(new EntityReference("account", _account1Id));
relatedEntities.Add(new EntityReference("account", _account2Id));
relatedEntities.Add(new EntityReference("account", _account3Id));
// Create an object that defines the relationship between the contact and account.
Relationship relationship = new Relationship("account_primary_contact");
//Associate the contact with the 3 accounts.
_service.Associate("contact", _contactId, relationship, relatedEntities);
Console.WriteLine("The entities have been associated.");
//Disassociate the records.
_service.Disassociate("contact", _contactId, relationship, relatedEntities);
설명
Message Availability
이 메시지는 호출자가 서버에 연결되어 있는지 아니면 오프라인인지에 관계없이 작동합니다.
Privileges and Access Rights
To perform this action, the caller must have privileges on the entity that is specified in the entityName parameter and access rights on the records that are specified in the entityId and relatedEntities parameters. For a list of the required privileges, see Disassociate Privileges.
Notes for Callers
This method removes multiple associations in one transaction between the record that is specified by the entityId parameter and each record in the relatedEntities parameter for the relationship that is specified in the relationship parameter.
For a one-to-many relationship, this method clears the ReferencingAttribute in the related record to the value of entityId.
For a many-to-many relationship, this method deletes a record in the intersect table for the relationship. The intersect table name is defined in the IntersectEntityName property for the relationship. You need this when you query for the records. However, you need the relationship name to set the Relationship property. This name is defined in the SchemaName property for the relationship.
For more information about the exceptions that can be thrown when this method is called, see Handle Exceptions in Your Code.
Supported Entities
You can use this method to disassociate any records that participate in a relationship, including records for custom entities.
스레드 보안
이 형식의 공용 정적(Visual Basic에서는 Shared) 구성원은 스레드로부터 안전합니다. 인스턴스 구성원은 스레드로부터 안전하지 않을 수 있습니다.
플랫폼
Development Platforms
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.
Target Platforms
Windows Server 2008,Windows Server 2012,Windows 7
Change History
참고 항목
참조
IOrganizationService 인터페이스
IOrganizationService 구성원
Microsoft.Xrm.Sdk 네임스페이스
DisassociateRequest
DisassociateResponse
Entity Metadata
Disassociate
기타 리소스
Sample: Associate (Early Bound)
Customize Entity Relationship Metadata
Handle Exceptions in Your Code
Troubleshooting and Error Handling
Send comments about this topic to Microsoft.
© 2015 Microsoft. All rights reserved.