Wednesday, 26 August 2015

fetch xml to query expression

Some times its easier to get fetch xml using advance find, but then to use it in query expression use the following command, this take fetchxml and then returns the query expression object


var conversionRequest = new Microsoft.Crm.Sdk.Messages.FetchXmlToQueryExpressionRequest


{

FetchXml = fetchXml

};
var conversionResponse =

(Microsoft.Crm.Sdk.Messages.FetchXmlToQueryExpressionResponse)_service.Execute(conversionRequest);

QueryExpression queryExpression = conversionResponse.Query;