I have decided to gather some of the most used functionalities into a single Nuget Package when coding C# against Dynamics CRM.
The package allows users to connect to Dynamics CRM and execute fetchXML queries in an easy fashion. I will add more functionalities in the feature and keep the post updated.
https://www.nuget.org/packages/Cive.DynamicsCRM.Extensions/
Package Manager Command:
Install-Package Cive.DynamicsCRM.Extensions -Version 1.0.2
After getting the Nuget Package into your project add the following using statement.
using Cive.DynamicsCRM.Extensions;
Examples:
Connect to CRM instance and get IOrganizationService interface:
var service = CRMConnection.GetOrganizationService("crmorganizationurl", "username", "password");
Connect to CRM instance and get CRMServiceClient which also contains IOrganizationService and other useful information
var client= CRMConnection.GetServiceClient("crmorganizationurl", "username", "password");
After establishing connection and getting the service object, you can execute fetchXML methods.
Retrieving entities from CRM, following command can only retrieve up to 5000 records.
var records = CRMFetchXML.Retrieve(service, fetchXMLstring);
If you want to retrieve more than 5000 records, use the following code.
var records = CRMFetchXML.RetrieveMoreThan5000(service, fetchXMLstring, 1000);
The last arguments defines the batch number.
Leave a comment below if you have any questions or suggestions.