This project is read-only.

Using the CRM entity class

Now that you've created a CRM entity class, there are a couple of steps needed in order to use it:

  • Creating an instance of the CrmControllerFactory class
  • Creating a CrmEntityController

Creating an instance of the CrmControllerFactory class:

All methods and classes in the framework are available through the CrmControllerFactory class. When you create an instance of this class, the connection with MS CRM is set up using the settings in the web.config file. Setting up the connection with CRM is a quite heavy operation, and in order to make this as smooth as possible the class is created as a singleton. This ensures that the connection is established only once.

Creating an instance of this class is simple:

ICrmControllerFactory factory = CrmControllerFactory.Instance;

Creating a CrmEntityController:

In order to use the CRM entity class created previously, you need to create a controller for the class. A CrmEntityController is a generic controller for doing operations on CRM entities, so you need to create a CrmEntityController object for each CRM entity class. Through the controller you can access methods like Create, Delete, Find, FindAll, Get and Update.

Here's an example of how you can create a CrmEntityController object for the CRM entity class created previously:

CrmEntityController<CrmContact> crmContactController = factory.GetEntityController<CrmContact>();

Complete example:

protected void Page_Load(object sender, EventArgs e)
     ICrmControllerFactory factory = CrmControllerFactory.Instance;
     CrmEntityController<CrmContact> crmContactController = factory.GetEntityController<CrmContact>();

     // Do work


Now that you have a CRM entity class, a CrmControllerFactory and a CrmEntityController you can start doing operations on the entities and their attributes.

Last edited Mar 13, 2012 at 11:05 AM by karolikl, version 9


No comments yet.