In the past my FetchXML was delivering me the result in xml format, but since I change server this function string ret = service.Fetch(fetchXml);
no longer works, so I had to resort with another solution, but this one give me more work to build a XML file.
Fetch String example:
string fetchXml = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
<entity name='account'>
<attribute name='name'/>
<attribute name='telephone1'/>
</entity>
</fetch>";
EntityCollection ec = organizationProxy.RetrieveMultiple(new FetchExpression(fetchXml));
XElement rootXml = new XElement("account");
foreach (Entity account in ec.Entities)
{
if (account.Attributes.Contains("name"))
{
rootXml.Add(new XElement("name", account.Attributes.Contains("name") ? account["name"] : ""));
rootXml.Add(new XElement("telephone1", account.Attributes.Contains("telephone1") ? account["telephone1"] : ""));
}
}
res.XmlContent = rootXml.ToString();
So what I'm doing here is build the XML string by hand, and I know that CRM can deliver the result in XML, I have googleit (http://social.msdn.microsoft.com/Forums/en-US/af4f0251-7306-4d76-863d-9508d88c1b68/dynamic-crm-2011-fetchxml-results-into-xmltextreader-to-build-an-xml-output) But this give me more work than my code. Or there is no other solution?