Migrating SDK Code from CRM4 to CRM5 (2011)

08Dec10

Now that the CRM5 beta is generally available (and many of us were privy to the preview code) it’s time to start dusting off those data access libraries and shaking them up to 2011 spec. If you’ve written any custom application code using the Microsoft.Crm.Sdk library, you’ll want to tune in here. Fortunately, I didn’t run into too many issues but there were a few gotchas that I’ll go into here in this post.

I was upgrading my open-source CRM query library, CrmQuery (which has saved us a ton of time over in our shop – I highly recommend that you check it out), so what I cover here is going to be limited to what I ran into during that migration. I’ll follow up with more posts when I start finding out more.

Namespace and Library Differences

First off, you’ll need to reference the Microsoft.Xrm.Sdk.dll library in your project. This replaces the CRM4 library Microsoft.Crm.Sdk.dll. Most of the types are the same name. Anywhere you’d use the namespaces:

using Microsoft.Crm.Sdk;
using Microsoft.Crm.Sdk.Query;

Becomes:

using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;

This was a bit confusing to me since I was familiar with the interim 4.0 SDK release that introduced what Microsoft referred to as “Xrm” which was basically a set of extensions and a new code generator to allow building proxies for the CRM services that could be queried using Linq. However in the 5.0 SDK, Microsoft has used the Xrm naming convention throughout the entire SDK, replacing most of the old Crm namespaces.

Type Differences

Certain base types have been removed, one of which being the column set base type which was used for anything that specified a list of columns to return or deal with in CRM. The use of the following type:

ColumnSetBase

Becomes simply:

ColumnSet

As a consequence, there is no Allcolumns type to represent all of the fields of an entity. Instead we create an instance of ColumnSet using a specialized constructor to indicate that we intend to specify all columns:

ColumnSet cols = new ColumnSet( true );

Collection Types

Members that formerly used the ArrayList type are now implemented using generic lists in the form of DataCollection For example:

LinkEntity.LinkEntities

Is no longer an ArrayList. Likewise, ConditionExpression.Values is now of the type:

[DataMemberAttribute]
public DataCollection<Object> Values { get; }

Notice also that there is no setter, so code that creates a collection and set this property will no longer work.

That’s it for now. If you liked this articled be sure to follow me on Twitter and if you’re interested in what we’re doing with CRM and other Microsoft technologies, be sure to follow us on Twitter here.

Advertisements


No Responses Yet to “Migrating SDK Code from CRM4 to CRM5 (2011)”

  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: