Dynamics CRM 构建IN查询

        CRM中有3种查询数据的方式分别是QueryExpression、fetchxml、linq,本篇讲述的条件IN的查询只支持前两种,linq并不支持。

     QueryExpression的写法如下,示例查询的是new_service实体中new_name的字段的值

var Names = new string[] { "刘庆", "王云帆" };
            var filter = new FilterExpression(LogicalOperator.And)
            {
                Conditions =
                    {
                        new ConditionExpression("new_name", ConditionOperator.In, Names)
                    }
            };
            var query = new QueryExpression("new_service")
            {
                ColumnSet = new ColumnSet(true),
                Criteria = filter
            };
  

      fetchxml的写法如下

<fetch version='1.0' output-format='xml-platform' mapping='logical'>
<entity name ='new_service'>
<attribute name ='new_name'/>
<filter type = 'and'>
<condition attribute = 'new_name' operator='in'>
<value>刘庆</value>
<value>王云帆</value>
</condition>
</filter>
</entity>
</fetch>

Dynamics CRM 构建IN查询_第1张图片



你可能感兴趣的:(crm,Dynamics,in查询,FetchXML,QueryExpression)