Introduction to Programming Models for Microsoft Dynamics CRM
Microsoft Dynamics CRM 2011 offers several programming paradigms designed to give you the flexibility to decide what works best for your needs. An early-bound entity data model has been added that includes an "object services" layer that integrates with the stack and exposes entity values as .NET Framework objects. You can also use the late-bound scenario, which has changed for Microsoft Dynamics CRM 2011.
The following diagram illustrates the key programmability scenarios for Microsoft Dynamics CRM 2011.
Use these Microsoft Dynamics CRM 2011 programming paradigms for the following:
Early-bound – Microsoft Dynamics CRM 2011 uses an entity data model and Windows Communication Foundation (WCF) Data Services technologies to provide a new set of tools that simplify the development of Internet-enabled applications that interact with Microsoft Dynamics CRM. This also enables an additional programming paradigm: an organization service context that tracks changes to objects and supports .NET Language-Integrated Query (LINQ) queries to retrieve data from Microsoft Dynamics CRM. For more information, see Use the Early Bound Entity Classes in Code.
Late-bound – This programming paradigm lets you write code that accesses entities that are not yet defined. For example, you may use this to write a custom search utility that will work for any installation of Microsoft Dynamics CRM, regardless of the customizations that you made. For more information, see Use the Late Bound Entity Class in Code. This paradigm also allows code to be written in a generic manner in such a way that it doesn't require a certain type of entity.
REST – The REST endpoint for AJAX and Microsoft Silverlight clients provides an alternative interface that you can use to work with Microsoft Dynamics CRM data. Rather than directly invoking the SOAP-based web service, you can execute requests using a service that is based on a URI. For more information, see Use the REST Endpoint for Web Resources.
WSDL – This programming paradigm lets you develop code from non-.NET clients, and does not depend on the use of Microsoft Dynamics CRM assemblies. For example, you can use this programming model to write code for Microsoft Dynamics CRM in Java. For more information, see Write Java and other Non-.NET Client Applications for Microsoft Dynamics CRM.
Program Using Early and Late Binding
In Microsoft Dynamics CRM 2011, you can choose from several programming scenarios to find the model that best suits your needs. The programming scenario in Microsoft Dynamics CRM 4.0 used the Web Services Description Language (WSDL) with early bound classes for each entity, and the DynamicEntity class for late-bound programming. You were also required to use late-bound programming for plug-in and custom workflow development. All of this has changed with the new programming models.
The main development scenario for Microsoft Dynamics CRM 2011 no longer uses the WSDL. Instead, you now reference two assemblies that allow you to connect to any Microsoft Dynamics CRM system for both early and late bound types. This scenario can be described as late binding or loosely typed. To use late bound types, use the Entity class. This class defines a collection of attributes that can be used to get and set the values of attributes. To use this model, the exact logical name must be known (and specified) as a string.
Alternatively, you can use early bound classes generated directly from the metadata, which include all customizations. The generated classes provide early binding and IntelliSense to aid you as you write custom code. For more information, see Create Early Bound Entity Classes with the Code Generation Tool (CrmSvcUtil.exe). For more information about programming by using the entity data model, see Summary of Changes Between Versions. For scenarios that use the WSDL, see Use the WSDL Endpoint for Microsoft Dynamics CRM.
In Microsoft Dynamics CRM 4.0, the entity class structure consisted of the following:
In Microsoft Dynamics CRM 2011, the entity class structure has been simplified to the following:
The DynamicEntity class has been replaced by the base class Entity. This means that all types are discoverable at both build time and runtime, making all strongly-typed entities now loosely-typed entities. You can use both programming scenarios in the same code as shown in the following example:
Account entity = new Account(); entity["name"] = "My Account"; //loosely typed, late binding entity.AccountNumber = "1234"; //strongly typed, early binding
The Microsoft Dynamics CRM SDK documentation includes samples that use both programming scenarios. The early bound samples use a file of strongly-typed classes that are generated with the code generation utility from a new, uncustomized installation of Microsoft Dynamics CRM. To run the samples, you must generate a file of strongly-typed classes from your installation. You can decide whether to create a proxy assembly from the generated code file or to include the file in your project directly, as we have done for the samples. For more information about your development style choices, see Choose your Development Style for Managed Code for Microsoft Dynamics CRM.
More information can be found in the following white papers:
Microsoft Dynamics CRM 2011 and Microsoft Dynamics CRM Online
Send comments about this topic to Microsoft.
© 2012 Microsoft Corporation. All rights reserved.