CRM多表链接查询+分页

 ConditionExpression condition2 = new ConditionExpression();
            condition2.AttributeName = "accountcategorycode";
            condition2.Operator = ConditionOperator.Equal;
            condition2.Values.Add(0);
            ConditionExpression condition3 = new ConditionExpression();
            condition3.AttributeName = "name";
            condition3.Operator = ConditionOperator.Like;
            condition3.Values.Add("%" + txtKeyWord.Text.Trim() + "%");
            ConditionExpression condition6 = new ConditionExpression();
            condition6.AttributeName = "parentaccountid";
            condition6.Operator = ConditionOperator.Null;
            FilterExpression filter1 = new FilterExpression();
            filter1.Conditions.Add(condition2);
            if (txtKeyWord.Text.Trim().Length > 0)
            {
                filter1.Conditions.Add(condition3);
            }
            if (cbxaccount.Checked == true)
            {
                filter1.Conditions.Add(condition6);
            }
            FilterExpression filter2 = new FilterExpression(LogicalOperator.Or);
            ConditionExpression condition4 = new ConditionExpression();
            condition4.AttributeName = "crm_is_group";
            condition4.Operator = ConditionOperator.Null;
            ConditionExpression condition5 = new ConditionExpression();
            condition5.AttributeName = "crm_is_group";
            condition5.Operator = ConditionOperator.Equal;
            condition5.Values.Add(100000001);
            filter2.Conditions.Add(condition4);
            filter2.Conditions.Add(condition5);
            QueryExpression query = new QueryExpression("account");
            query.ColumnSet.AddColumns("accountid", "name", "crm_cust_state", "crm_cust_certtype", "crm_cust_certno", "telephone1", "fax", "telephone3", "emailaddress1", "fax", "parentaccountid");
            query.Criteria.AddFilter(filter1);
            query.Criteria.AddFilter(filter2);

            LinkEntity linkEntity = new LinkEntity("account", "crm_tradeaccount", "accountid", "crm_account", JoinOperator.Inner);
            ConditionExpression conLink = new ConditionExpression();
            conLink.AttributeName = "crm_distributor_netcode";
            conLink.Operator=ConditionOperator.Equal;
            conLink.Values.Add(_distributor_netcode);
            linkEntity.LinkCriteria.AddCondition(conLink);
            query.LinkEntities.Add(linkEntity);
            query.Distinct = true;

            query.AddOrder("name", OrderType.Ascending);

query.PageInfo
= new PagingInfo(); query.PageInfo.Count = GridView1.PageSize; query.PageInfo.PageNumber = (GridView1.PageIndex + 1); query.PageInfo.PagingCookie = null; query.PageInfo.ReturnTotalRecordCount = true; Method method = new Method();//OrganizationServiceProxy或者IOrganizationService类型对象 EntityCollection entitys = method.RetrieveMultiple(query);

 

转载于:https://www.cnblogs.com/lmy213/p/3272377.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值