Szerkesztés

Megosztás a következőn keresztül:


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 FetchXML Builder in the XrmToolBox.

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

Null column values are not returned

When a table column contains a null value, or if the column wasn't requested, the record returned won't include the value. There isn't a key to access it or a value to return. The absence of the attribute indicates that it's null. This is the behavior using the SDK for .NET. Learn more about this behavior

Columns that are not valid for read always return null values. The definition of these columns have the AttributeMetadata.IsValidForRead property set to false.

Next steps

Learn how to select columns.

Try some sample code