Partager via


OrganizationServiceContext.AddRelatedObject Method

Definition

Adds a related entity to the OrganizationServiceContext and creates the link that defines the relationship between the two entities in a single request.

public:
 void AddRelatedObject(Microsoft::Xrm::Sdk::Entity ^ source, Microsoft::Xrm::Sdk::Relationship ^ relationship, Microsoft::Xrm::Sdk::Entity ^ target);
public void AddRelatedObject (Microsoft.Xrm.Sdk.Entity source, Microsoft.Xrm.Sdk.Relationship relationship, Microsoft.Xrm.Sdk.Entity target);
member this.AddRelatedObject : Microsoft.Xrm.Sdk.Entity * Microsoft.Xrm.Sdk.Relationship * Microsoft.Xrm.Sdk.Entity -> unit
Public Sub AddRelatedObject (source As Entity, relationship As Relationship, target As Entity)

Parameters

source
Entity

The parent entity that is being tracked by the context.

relationship
Relationship

The name of the attribute or navigation property that returns the related object based on an association between the two entities.

target
Entity

The related object that is being added.

Remarks

This method essentially works by calling AddObject(Entity) and AddLink(Entity, Relationship, Entity).

Applies to