This project is read-only.

Xrm FetchXml Data Provider

.NET Framework Data Provider for Dynamics CRM FetchXml


Get the entity record from Dynamics CRM in the same way to get from database.
Provide follow classes. You'll can guess how to use easily.
  • FetchXmlClientFactory
  • FetchXmlConnection
  • FetchXmlCommand
  • FetchXmlDataReader


Command text use FetchXML instead of sql statement.
Using Simplified Connection to Microsoft Dynamics CRM in Connection strings.


PM> Install-Package XrmLib.Data.FetchXmlClient


fetch.xml (ref. FetchXML schema)
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
  <entity name="account">
    <attribute name="name" />
    <attribute name="telephone1" />
    <attribute name="primarycontactid" />
    <order attribute="name" descending="false" />
    <filter type="and">
      <condition attribute="statecode" operator="eq" value="0" />
    <link-entity name="contact" from="contactid" to="primarycontactid" visible="false" link-type="outer" alias="primarycontact">
      <attribute name="emailaddress1" />

app.config (ref. Simplified Connection to Microsoft Dynamics CRM)
<?xml version="1.0" encoding="utf-8" ?>
    <add name="mycrm" connectionString="Url=https://server/org; Username=user01; Password=xxxx" />

sample code
var query = File.ReadAllText("fetch.xml");
using (var cnn = new FetchXmlConnection("mycrm"))
using (var cmd = new FetchXmlCommand(query, cnn))
using (var reader = cmd.ExecuteReader())
    var dt = new DataTable();
    dataGridView1.DataSource = dt;

Last edited Sep 29, 2014 at 4:45 PM by yamamo, version 11