簡體   English   中英

以編程方式檢索所有子代/后代/相關實體

[英]Retrieve all child/descendant/related entities programmatically

如何使用C#在CRM Dynamics 2011中檢索源實體的所有相關實體?

謝謝

FetchXml不能滿足此要求,但是很顯然,如果您想構造FetchXml並將其用於QueryBase來代替QueryExpressionQueryBase您展示。 邏輯保持不變。

//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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM