Get Related Entities

Example to get the list of emails associated to the Contact :

entity is the Contact entity
RelationShipName : Contact_Emails

public static IEnumerable GetRelatedEntitiesExtended(OrganizationServiceContext ctx, Entity entity, RelationShipName
relationshipShemaName) where T : Entity
ctx.MergeOption = MergeOption.NoTracking;
ctx.LoadProperty(entity, new Relationship(relationshipShemaName.ToString()));
//Microsoft.Xrm.Client for SKD 2015
return entity.GetRelatedEntities(relationshipShemaName.ToString());

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s