我必须创建“介于日期之间”的条件。

当我这样写的时候:

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


startDateendDateDateTime。我在modifiedOnCondition.Values上出错。它说:


  无法将属性或索引器'Microsoft.Xrm.Sdk.Query.ConditionExpression.Values'分配给它-只读


我该如何解决?

最佳答案

创建对象后,您无法更改Values属性,只需将其作为参数传递给ConditionExpression构造函数即可:

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

08-26 16:20