0

How could I parse the result of the following FetchXML request?

string fetch_checkEntity = @"
     <fetch mapping='logical'>
       <entity name='" + entityname + @"'>
         <attribute name='" + columnname + @"' />
         <attribute name='" + logicalnameid + @"' />
         <order attribute='" + columnname + @"' />
           <filter>
             <condition attribute='statecode' operator='eq' value='0' />
             <condition attribute='statuscode' operator='eq' value='1' />
           </filter>
         </entity>
       </fetch>";

string result_checkEntity = crmService.Fetch(fetch_checkEntity);
ccellar
  • 10,326
  • 2
  • 38
  • 56
Vineeta
  • 31
  • 1
  • 1
  • 5

1 Answers1

0

I recommend using XDocument features to parse the results of fetch statement.
I don't know exactly how the resultset would look like but here are some hints on how to do the parsing.

XDocument xml = XDocument.Parse(result_checkEntity);  

var results = from item in xml.Elements("result")  
               select new  // creating an anonymous type
               {  
                   element = (type of value) //casting operation to what you have: string, Guid, etc
                             item.Element("  ") // in the paranthesis put the name 
                                                // of the element you are interesting 
                                                // in getting back; columnname 
               }; 
Arabela Paslaru
  • 6,754
  • 1
  • 15
  • 10