Fetching data from the CRM database

As we discussed in an earlier topic, we have two direct methods available to get data from CRM: Retrieve and RetrieveMultiple. The Retrieve method only fetches a single record based on the primary key passed to it, but RetrieveMultiple can fetch one or more records based on the query passed to it. To write a query for the RetrieveMultiple method we can use the following different options:

  • QueryByAttribute
  • QueryExpression
  • FetchXML


QueryByAttribute is the simplest way to build your query to fetch data. But it does not provide options to define complex criteria to get data from the CRM. For example, the QueryByAttribute class can't be used to get data based on a conditional operator such as: fetch ...

Get Microsoft Dynamics CRM 2015 Application Design now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.