1 回答

TA貢獻(xiàn)1789條經(jīng)驗(yàn) 獲得超10個(gè)贊
確定使用以下查詢僅檢索客戶及其相關(guān)聯(lián)系人。我可以檢索帳戶及其相關(guān)聯(lián)系人?,F(xiàn)在獲取這些帳戶及其 ID,并使用第二個(gè)查詢來(lái)獲取 Notes(注釋),您將為 Notes 做同樣的事情。
<fetch>
<entity name="account" >
<attribute name="name" />
<link-entity name="contact" from="parentcustomerid" to="accountid" link-type="inner" >
<attribute name="fullname" />
</link-entity>
</entity>
</fetch>
檢索筆記的查詢:
<fetch>
<entity name="annotation" >
<attribute name="filename" />
<attribute name="documentbody" />
<attribute name="isdocument" />
<link-entity name="account" from="accountid" to="objectid" link-type="inner" >
<filter type="and" >
<condition attribute="accountid" operator="eq" value="AccountGuid" />
</filter>
</link-entity>
</entity>
</fetch>
C# 代碼示例
string fetch = @"
<fetch>
<entity name='account' >
<attribute name='name' />
<link-entity name='contact' from='parentcustomerid' to='accountid' link-type='inner' alias='Contact' >
<attribute name='fullname' alias = 'Contact.Fullname' />
</link-entity>
</entity>
</fetch> ";
EntityCollection Coll = CrmConn.RetrieveMultiple(new FetchExpression(fetch));
foreach (Entity acunt in Coll.Entities)
{
Console.WriteLine("Name of Account: " + acunt.GetAttributeValue<string>("name"));
Console.WriteLine("Name of Contact: " + acunt.GetAttributeValue<AliasedValue>("Contact.Fullname").Value);
}
- 1 回答
- 0 關(guān)注
- 99 瀏覽
添加回答
舉報(bào)