![](/img/trans.png)
[英]Retrieve a list of entites from CRM 2011, each with all of their related entities
[英]Retrieve all child/descendant/related entities programmatically
如何使用C#在CRM Dynamics 2011中檢索源實體的所有相關實體?
謝謝
FetchXml不能滿足此要求,但是很顯然,如果您想構造FetchXml並將其用於QueryBase
來代替QueryExpression
我QueryBase
您展示。 邏輯保持不變。
//Assumes you have a Entity() object of the parent entity
//somehow you have to know the parent entity record's Id
Guid parentId = parentEntity.Id;
var query = new QueryExpression("new_childentity");
query.Criteria.AddCondition(new ConditionExpression("new_lookupfield", ConditionOperator.Equal, parentId));
query.ColumnSet = new ColumnSet(true);
var results = service.RetrieveMultiple(query);
if (results.Entities.Any())
{
//Do your processing here
}
else
{
//Do whatever when there are no child entities
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.