0

I'm learning how to use CRM Web API with .NET Core to work with entities and I found this very useful library. There is an option to retrieve record data using FetchXML.

string fetchXml = "<fetch mapping='logical'><entity name='account'><attribute name='accountid'/><attribute name='name'/></entity></fetch>";
var fetchResults = await api.GetList("accounts", QueryOptions: new CRMGetListOptions() { FetchXml = fetchXml });

Is there any option how to compose more easily and elegantly the fetchXML, for example by using QueryExpression (Microsoft.CrmSdk.CoreAssemblies) or something similar?

Manuel Mannhardt
  • 2,191
  • 1
  • 17
  • 23
Banana Cake
  • 1,172
  • 1
  • 12
  • 31

2 Answers2

0
  1. Design the Advanced find query & download the fetchxml
  2. Develop fetchxml queries using XrmToolBox FetchXML builder

You can use QueryExpressionToFetchXmlRequest to convert the QueryExpression into FetchXml.

Read more

  • the QueryExpressionToFetchXmlRequest would be good, but I can not use IOrganizationService in .NET Core so I don't know how to use it there and if is possible. – Banana Cake Oct 09 '19 at 09:06
0

I have found Mike Ochs's FetchXmlWrapper helpful in certain projects.

More info: https://www.cobalt.net/2014/06/25/performance-improvements-using-fetch-xml-wrapper/

Aron
  • 3,877
  • 3
  • 14
  • 21