Как вы анализируете результат запроса FetchXML? - PullRequest
0 голосов
/ 18 сентября 2011

Как я могу проанализировать результат следующего запроса FetchXML?

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);

1 Ответ

0 голосов
/ 18 сентября 2011

Я рекомендую использовать функции XDocument для анализа результатов оператора выборки.
Я не знаю точно, как будет выглядеть resultset, но вот несколько советов о том, как выполнить синтаксический анализ.

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 
               }; 
...