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.