在 QueryExpression 中包含 OptionSetValue

Includ OptionSetValue in QueryExpression

我需要查询 OptionSetValue 字段以根据基于特定 ID 完成的查询查找活动记录。但是,每次执行下面的查询时,我都会收到以下错误:

the type with data contract name optionsetvalue is not expected

如何在 QueryExpression ConditionValues 属性中包含 OptionSetValue

queryEx = new QueryExpression
{
    EntityName = "account",
    ColumnSet = new ColumnSet(true),
    Criteria =
    {
        FilterOperator = LogicalOperator.And,
        Conditions =
        {
            new ConditionExpression
            {
                AttributeName = "neu_id",
                Operator = ConditionOperator.Equal,
                Values = {agency.ReferenceNumber}
            },
            new ConditionExpression
            {
                AttributeName = "neu_appointmentstatus",
                Operator = ConditionOperator.Equal,
                Values = {new OptionSetValue(279660000)}
            }
        }
    }
};

EntityCollection collection = _client.RetrieveMultiple(queryEx);

在您的情况下,您需要设置选项集的整数值。 所以代码将是:

new ConditionExpression
    {
        AttributeName = "neu_appointmentstatus",
        Operator = ConditionOperator.Equal,
        Values = 279660000
    }