I am up to my eyes in workflows today and I was trying to do a query to retrieve some items, so I had to refresh myself how to do it in CRM 4. I thought I would try the sample code and when I pasted it a bit in, I got this error
Error:
Property or indexer ‘Microsoft.Crm.Sdk.Query.FilterExpresssion.Conditions’ cannot be assigned to — it is read only
The problem line of code was this one
filterPrincipal.Conditions = new ConditionExpression[] {conditionPrincipal};
There is nothing more frustrating when the sample code doesn’t work or compile. The answer was oddly simple and I assume they must have changed how it worked sometime after CRM 4 was released and maybe I haven’t updated my sample code.
Anyway as the message said read only I used a bit of of intellisense to see what I could do with the condition and found there was an add.
So instead of assigning the Condition you have to add it like this.
filterPrincipal.Conditions.Add(conditionPrincipal);