4

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?

Nikolay Kostov
  • 15,454
  • 21
  • 81
  • 119
Jungleman
  • 257
  • 2
  • 6
  • 17

1 Answers1

5

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 });
Adriano Repetti
  • 62,720
  • 18
  • 132
  • 197