此代码从 CRM 2011 REST 服务 API 接收 ATOM 提要。它有效,但似乎非常冗长,但我找不到更有效的方式来使用响应。我将不胜感激任何建议,或者如果我的问题需要更具体,我会问这是推荐的方法吗?到目前为止,我在 CRM SDK 或 MSDN 中对此一无所知。
XmlDocument xml = new XmlDocument();
xml = xrm.GetXMLData(query);
XDocument xdoc = XDocument.Parse(xml.OuterXml);
XNamespace d = "http://schemas.microsoft.com/ado/2007/08/dataservices";
XNamespace m = "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata";
XNamespace atom = "http://www.w3.org/2005/Atom";
foreach (var entity in xdoc.Descendants(atom + "entry"))
{
var psi = entity.Element(atom + "content")
.Element(m + "properties")
.Element(d + "new_name");
var status = entity.Element(atom + "content")
.Element(m + "properties")
.Element(d + "new_ExternalStatus");
UpdateExternalDBStatus(psi.Value, status.Value);
}