1 回答
TA贡献1789条经验 获得超10个赞
确定使用以下查询仅检索客户及其相关联系人。我可以检索帐户及其相关联系人。现在获取这些帐户及其 ID,并使用第二个查询来获取 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 关注
- 80 浏览
添加回答
举报