FetchXmlToQueryExpression Message (CrmService)
![]() |
[Applies to: Microsoft Dynamics CRM 4.0]
Find the latest SDK documentation: CRM 2015 SDK
| Works for all deployment types | Works online and offline |
Converts a query in Fetch XML to a QueryExpression.
The relevant classes are specified in the following table.
| Type | Class |
| Request | FetchXmlToQueryExpressionRequest |
| Response | FetchXmlToQueryExpressionResponse |
Remarks
To use this message, pass an instance of the FetchXmlToQueryExpressionRequest class as the request parameter in the Execute method.
For a list of required privileges, see FetchXmlToQueryExpression Privileges.
Example
The following code example demonstrates how to use the FetchXmlToQueryExpression message.
[C#]
// Set up the CRM service.
CrmAuthenticationToken token = new CrmAuthenticationToken();
// You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
token.AuthenticationType = 0;
token.OrganizationName = "AdventureWorksCycle";
CrmService service = new CrmService();
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;
// Create the request object.
FetchXmlToQueryExpressionRequest fetch = new FetchXmlToQueryExpressionRequest();
// Set the Fetch Xml to be converted.
// Be aware that using all-attributes may adversely affect
// performance and cause unwanted cascading in subsequent
// updates. A best practice is to retrieve the least amount of
// data required.
fetch.FetchXml = "<fetch mapping='logical'><entity name='account'><all-attributes/></entity></fetch>";
// Execute the request.
FetchXmlToQueryExpressionResponse qe = (FetchXmlToQueryExpressionResponse) service.Execute(fetch);
[Visual Basic .NET]
' Set up the CRM service.
Dim token As New CrmAuthenticationToken()
' You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
token.AuthenticationType = 0
token.OrganizationName = "AdventureWorksCycle";
Dim service As New CrmService()
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials
' Create the request object.
Dim fetch As New FetchXmlToQueryExpressionRequest()
' Set the Fetch Xml to be converted.
' Be aware that using all-attributes may adversely affect
' performance and cause unwanted cascading in subsequent
' updates. A best practice is to retrieve the least amount of
' data required.
fetch.FetchXml = _
"<fetch mapping='logical'>" + _
"<entity name='account'>" + _
"<all-attributes/>" + _
"</entity>" + _
"</fetch>"
' Execute the request.
Dim qe As FetchXmlToQueryExpressionResponse = CType(service.Execute(fetch), FetchXmlToQueryExpressionResponse)
See Also
Concepts
Reference
.gif)