问题
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?
回答1:
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 });
来源:https://stackoverflow.com/questions/22605180/cannot-be-assigned-to-it-is-read-only-error-on-conditionexpression