CRM 4 – You have to use the Add method in Queries

I have been doing some CRM 4 queries and using the ColumnSets etc.

One thing that has annoyed me is so many examples on the internet don’t seem to work.

The ColumnSet example on the Microsoft CRM documentation here, site and many other goes like this.

// Create a column set holding the names of the columns to be retrieved.
ColumnSet cols = new ColumnSet();
cols.Attributes = new string [] {"name", "accountid"};

but I had to do this

ColumnSet cols = new ColumnSet();

cols.AddColumns("ordernumber", "new_orderAccepted");
query.ColumnSet = cols;

there are other examples where the code needs to be changed to use the Add method.  I think
the reason for this might be something to do with the version of .NET but I'm not certain.
when you want to add an array of properties you also have to use the Add or AddRange method

List<Property> updatedFields = orderEntity.toPropertyList(crmService);


I thought I would add this blog post because it can be very frustrating when you try examples
on the internet and the SDK and then the examples don't work.

Leave a Reply

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

You are commenting using your 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