c# - 在 QueryExpression 中包含 OptionSetValue

标签 c# .net dynamics-crm-2011 dynamics-crm crm

我需要查询一个 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
    }

关于c# - 在 QueryExpression 中包含 OptionSetValue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27788848/

相关文章:

c# - 使用一个列表中的最大值对第二个列表进行排序。

iphone - 我应该开源我的 MonoTouch .NET iPhone 应用程序吗?

c# - 在 Windows 上用 C# 加载 linux 动态库 (.so)

javascript - CRM 中带有 OData 查询的时间戳

c# - 如何静态验证某些 C# 代码是否正常运行?

c# - 将(一些)Unicode 非间距标记与相关字母组合以进行统一处理

java - 查找函数时出错 'HelloWorld' : The specified procedure could not be found

dynamics-crm-2011 - 将 EntityReference 转换为 Entity

java - 通过 SOAP/Java 在 MS Dynamics CRM 2011 中创建产品

c# - 获取列表框中项目的索引c#