我正在尝试检索符合某个条件的联系人电子邮件列表(已经简化了条件的数量以使其尽可能简单),但我正在努力找出如何取出PartyList字段的Guids (例如,从,到& cc)。这是我写的代码......
string fetchXml = @"
<fetch mapping='logical'>
<entity name='email'>
<attribute name='subject'/>
<attribute name='regardingobjectid'/>
<attribute name='from'/>
<attribute name='to'/>
<attribute name='prioritycode'/>
<attribute name='statuscode'/>
<attribute name='modifiedon'/>
<attribute name='activityid'/>
<order descending='false' attribute='subject'/>
<link-entity name='contact' alias='ag' to='regardingobjectid' from='contactid'>
<filter type='and'>
<condition attribute='examplecondition' value='1' operator='eq'/>
<condition attribute='anotherexamplecondition' value='5' operator='eq'/>
</filter>
</link-entity>
</entity>
</fetch>";
XDocument document = crmService.ToXDocument(contactEmailfetchXml);
var results = document.Root.Elements("result").Select(e =>
new Email
{
ActivityId = e.Element("activityid").ToGuid(),
Subject = e.Element("subject").Val(),
//From = e.Element("from").Val(),
//To = e.Element("to").Val(),
//CC = e.Element("cc").Val(),
PriorityCode = e.Element("prioritycode").Val()
}).ToList();
'Val'扩展方法只是:
public static string Val(this XElement element)
{
return element != null
? element.Value
: String.Empty;
}
任何帮助都会非常感激。
感谢。