crm2011OrganizationServiceContext的事例

来源:互联网 发布:知乎怎么提问问题 编辑:程序博客网 时间:2024/04/29 07:08

    using System;
    using System.Linq;
    using Microsoft.Xrm.Sdk;
    using Microsoft.Xrm.Sdk.Client;

    public class ServiceContentHelper : OrganizationServiceContext
    {
        public ServiceContentHelper(Microsoft.Xrm.Sdk.IOrganizationService service) : base(service) { }

        public void Retrieve()
        {
            var entityArray = this.CreateQuery("new_supplyaccount").ToArray();
            if (entityArray != null)
            {
                System.Console.WriteLine("len: " + entityArray.Count());
                foreach(Entity en in entityArray){
                    DisplayEntity(en, "new_supplyaccount");
                }
            }
        }
        
        private void DisplayEntity(Entity entity, string label)
        {
            System.Console.WriteLine("display" + label + "start_________________________________");
            var keyArray = entity.Attributes.Keys;
            foreach (string name in keyArray)
            {
                System.Console.WriteLine("attributeName: " + name + ",attributeValue: " + entity.Attributes[name]);
            }
            System.Console.WriteLine("display" + label + "end!_________________________________");
        }
    }

0 0
原创粉丝点击