Use FetchXml to retrieve data

You can use FetchXml to retrieve data using either the SDK for .NET or Web API. With Power Automate, you can retrieve data using the Web API using the Fetch Xml Query parameter of the List Rows command.

You may also want to use Community tools like the XrmToolbox FetchXmlBuilder

How you retrieve data depends on whether you are using the SDK for .NET or Dataverse Web API.

Use the FetchExpression class to hold the FetchXml query as a string. FetchExpression is derived from the common QueryBase class type, so you can use it when that type is a method parameter or class property.

You should use the IOrganizationService.RetrieveMultiple method for most cases.

static EntityCollection RetrieveMultipleExample(IOrganizationService service, string fetchXml)
{
   return service.RetrieveMultiple(new FetchExpression(fetchXml));
}

You can also use the RetrieveMultipleRequest class with the IOrganizationService.Execute method, but there are few scenarios where this is necessary.

static EntityCollection RetrieveMultipleRequestExample(IOrganizationService service, string fetchXml)
{
   var request = new RetrieveMultipleRequest()
   {
         Query = new FetchExpression(fetchXml)
   };

   var response = (RetrieveMultipleResponse)service.Execute(request);

   return response.EntityCollection;
}

Quickstart: Execute an SDK for .NET request (C#)
Learn more about using messages with the SDK for .NET

Next steps

Learn how to select columns.

Try some sample code