Dynamic CRM Operations With Your ASP.NET Application

Introduction
 
Start your Dynamics CRM operations from your ASP.NET application. In this article we will learn and look how to connect Dynamics CRM.
We need to download CRM SDK to connect CRM.
 
For more information you can refer to this link.  
 
About SDK and Useful Libraries information
  1. using microsoft.crm.sdk.proxy.dll;    
  2.     
  3. using microsoft.xrm.sdk.dll;    
  4.     
  5. using microsoft.xrm.client.dll;    
Conceptual Information
 
CRM SDK provides required essentials  to make proper connection,
 
 
 
Define Data Connection
 
In this section, learn how to define Dynamics CRM Connection, 
  1. OrganizationService service = new OrganizationService("YourCRMConnectionString");  
Organization service is the data connection class, 
  1. String YourCRMConnectionString = @"Url=http://Servername/yourworkCatalog; Domain=mydomain; Username=*******; Password=*****;"  
Other values,
  1. service.Server = "Servername";  
  2. service.user = "username";  
  3. service.organization = "*****";  
Simple format otherwise,
  1. <connectionStrings>  
  2.     <add name="Server=servername, organization=YourCatalogworks, user=****" connectionString="Url=http://myserver/AdventureWorksCycle; Domain=SalesLabs; Username=maruthi; Password=********;" />  
  3. </ connectionStrings>  
Get Sample Record
 
The following business logic helps you to get Sample Account Records,
  1. public List < SampleAccountEntryRecords > GetRecords()   
  2. {  
  3.         using(OrganizationService service = new OrganizationService("YourCRMConnectionString"))   
  4.         {  
  5.                 QueryExpression query = new QueryExpression   
  6.                 {  
  7.                     EntityName = "account",  
  8.                         ColumnSet = new ColumnSet("accountid""name""revenue""numberofemployees""primarycontactid")  
  9.                 };  
  10.                 List < SampleAccountEntryRecords > info = new List < SampleAccountEntryRecords > ();  
  11.                 EntityCollection accountRecord = service.RetrieveMultiple(query);  
  12.         }  
  13. }  
Sample Data Model
  1. public class SampleAccountEntryRecords  
  2. {  
  3.     public Guid AccountID   
  4.   {  
  5.         get;  
  6.         set;  
  7.     }  
  8.     public string AccountName   
  9.     {  
  10.         get;  
  11.         set;  
  12.     }  
  13.     public int NumberOfEmployees   
  14.     {  
  15.         get;  
  16.         set;  
  17.     }  
  18.     public Money Revenue   
  19.     {  
  20.         get;  
  21.         set;  
  22.     }  
  23.     public EntityReference PrimaryContact   
  24.     {  
  25.         get;  
  26.         set;  
  27.     }  
  28.     public string PrimaryContactName   
  29.     {  
  30.         get;  
  31.         set;  
  32.     }  
  33.     public decimal RevenueValue   
  34.     {  
  35.         get;  
  36.         set;  
  37.     }  
  38. }  
The above snippets help us to get records from CRM.
 
  
 
References: For more information refer the link,
 
MVC Model Sample:  MVC Model


Similar Articles