码迷,mamicode.com
首页 > 其他好文 > 详细

crm2011QueryByAttribute的事例

时间:2014-06-08 03:26:22      阅读:245      评论:0      收藏:0      [点我收藏+]

标签:querybyattribute   crm2011   

    using System;
    using Microsoft.Xrm.Sdk;
    using Microsoft.Xrm.Sdk.Query;

    public class QueryByAttributeHelper
    {
        public void Retrieve(IOrganizationService service)
        {
            //构造查询
            QueryByAttribute query = new QueryByAttribute();
            query.EntityName = "new_supplyaccount";
            query.ColumnSet = new ColumnSet("new_name");

            //查询条件
            query.Attributes.AddRange("statecode");
            query.Values.AddRange(0);

            EntityCollection returnCollection = service.RetrieveMultiple(query);
            if (returnCollection != null && returnCollection.Entities.Count > 0)
            {
                foreach(Entity en in returnCollection.Entities)
                {
                    DisplayEntity(en);
                }
            }
        }

        private void DisplayEntity(Entity entity)
        {
            System.Console.WriteLine("start_________________________________");
            var keyArray = entity.Attributes.Keys;
            foreach (string name in keyArray)
            {
                System.Console.WriteLine("attributeName: " + name + ",attributeValue: " + entity.Attributes[name]);
            }
            System.Console.WriteLine("end_________________________________");
        }
    }

crm2011QueryByAttribute的事例,布布扣,bubuko.com

crm2011QueryByAttribute的事例

标签:querybyattribute   crm2011   

原文地址:http://blog.csdn.net/y_f123/article/details/29224871

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!