Hello,
I write currently a CRM 2011 plugin and in the Microsoft.Xrm.Client.dll there is the extension GetRelatedEntity().
Microsoft.Xrm.Client.dll i can not use in plugins, because the dll is not available on the crm server. Is there another way to get easily the related entities?
The other way i found is to read the related entities by a self written query, but this is a common task right also should be there a method provided by microsoft.
Anybody a idea ?
---------------------- query i am using ---------------------------
QueryExpression query = new QueryExpression();
query.EntityName = "invoice";
query.ColumnSet = new ColumnSet(true);
Relationship relationship = new Relationship();
query.Criteria = new FilterExpression();
query.Criteria.AddCondition(new ConditionExpression("statecode", ConditionOperator.Equal, "Active"));
relationship.SchemaName = "prg_invoice_prg_abrechnungsposition";
RelationshipQueryCollection relatedEntity = new RelationshipQueryCollection();
relatedEntity.Add(relationship, query);
RetrieveRequest request = new RetrieveRequest();
request.RelatedEntitiesQuery = relatedEntity;
request.ColumnSet = new ColumnSet(new string[] { "prg_abrechnungspositionid" });
request.Target = new EntityReference { Id = dienstleistungposition.prg_abrechnungspositionId.Value, LogicalName = "prg_abrechnungsposition" };
RetrieveResponse response = (RetrieveResponse)localContext.OrganizationService.Execute(request);
-----------------------------------------------------------------------------------------------------------