Team & users are N:N related. I might need to right
long LinkEntity query to retrieve users for particular
team. Guess what, I can do it using RelatedEntitiesQuery
property of RetrieveRequest .
QueryExpression query = new QueryExpression();
query.EntityName = "systemuser";
query.ColumnSet = new ColumnSet("systemuserid");
Relationship relationship = new Relationship();
query.Criteria = new FilterExpression();
query.Criteria.AddCondition(new ConditionExpression("isdisabled",
query.EntityName = "systemuser";
query.ColumnSet = new ColumnSet("systemuserid");
Relationship relationship = new Relationship();
query.Criteria = new FilterExpression();
query.Criteria.AddCondition(new ConditionExpression("isdisabled",
ConditionOperator.Equal, false));
// name of relationship between team & systemuser
relationship.
SchemaName = "teammembership_association"; RelationshipQueryCollection relatedEntity = new RelationshipQueryCollection(); relatedEntity.Add(relationship, query);
RetrieveRequest request = new RetrieveRequest(); request.RelatedEntitiesQuery = relatedEntity;
request.ColumnSet = new ColumnSet("teamid");
request.Target = new EntityReference { Id = teamId, LogicalName = "team" }; RetrieveResponse response = (RetrieveResponse)service.Execute(request);
SchemaName = "teammembership_association"; RelationshipQueryCollection relatedEntity = new RelationshipQueryCollection(); relatedEntity.Add(relationship, query);
RetrieveRequest request = new RetrieveRequest(); request.RelatedEntitiesQuery = relatedEntity;
request.ColumnSet = new ColumnSet("teamid");
request.Target = new EntityReference { Id = teamId, LogicalName = "team" }; RetrieveResponse response = (RetrieveResponse)service.Execute(request);
if (((DataCollection)
No comments:
Post a Comment