Early bound classes

If you want to enjoy intelliSense support during development, you can use early bound classes. Microsoft CRM 2011 provides us with the ability to generate a class from its metadata, which includes all OOB and custom entity customization. Microsoft CRM SDK comes with a utility, CrmSvcUtil, that can be used to generate early bound classes. It creates a class file that includes strongly typed classes for all Microsoft CRM entities. This tool creates one class for each entity and provides intelliSense support during development.

You can refer to the following syntaxes to generate early bound classes depending on your deployment.

On-premise deployment

For on-premise deployment, use the following syntax:

CrmSvcUtil.exe /url:http://<servername>/<organizationname>/XRMServices/2011/Organization.svc
    /out:<outputfilename>.cs /username:<username> /password:<password> /domain:<domainname>
    /namespace:<outputnamespace> /serviceContextName:<service context name>

Online deployment

If you are using online deployment, you can use the following syntax:

CrmSvcUtil.exe
/url:https://myorg.crm.dynamics.com/XRMServices/2011/Organization.svc
/out:GeneratedCode.cs /username:[email protected]
/password:yourpassword!

IFD deployment

If you are using IFD deployment, you need to use the following syntax:

CrmSvcUtil.exe
/url:https://myorg.crm.com:555/XRMServices/2011/Organization.svc
/out:GeneratedCode.cs /username:administrator /password:yourpassword

Tip

You can refer to http://msdn.microsoft.com/en-us/library/gg327844.aspx for more details on the CrmSvcUtil utility.

Once an early bound class is generated, it can be added in our application to connect to our organization. We can refer to our OOB entity and custom entity directly in our code. Early bound classes basically provide compile-time checking for all entity and attribute types. The following code snippet is an example of creating a contact record using an early bound class:

Contact contact = new Contact(){
   FirstName = "Mahender",
   LastName = "Pal",
   Address1_StateOrProvince = "Haryana",
   Address1_PostalCode = "131001",};
Guid _contactId = _serviceProxy.Create(contact);

An early bound class provides intelliSense support and compile-time validation, which help us to decrease our development time, but it also adds overhead to generate early bound classes every time we make any customization changes.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.225.234.24