首页 > 其他 > 详细

crm2011QueryByAttribute的事例

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

    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的事例

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!