Question

I have to create "between date" condition.

When I write like this:

ConditionExpression modifiedOnCondition = new ConditionExpression();
modifiedOnCondition.AttributeName = "modifiedon";
modifiedOnCondition.Operator = ConditionOperator.Between;
modifiedOnCondition.Values = new Object[] { startDate, endDate };

startDate and endDate are DateTime. I got an error on modifiedOnCondition.Values. It says:

Property or indexer 'Microsoft.Xrm.Sdk.Query.ConditionExpression.Values' cannot be assigned to -- it is read only

How can I fix it?

Was it helpful?

Solution

You can't change Values property after object has been created, just pass it as parameter in ConditionExpression constructor:

var modifiedOnCondition = new ConditionExpression(
    "modifiedon",
    ConditionOperator.Between,
    new Object[] { startDate, endDate });
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top