zoukankan      html  css  js  c++  java
  • crm高速开发之EntityCollection

    /* 创建者:菜刀居士的博客
     * 创建日期:2014年07月07号
     */

    namespace Net.CRM.OrganizationService
    {
        using System;
        using Microsoft.Xrm.Sdk;
        using Microsoft.Xrm.Sdk.Query;

        /// <summary>
        /// EntityCollection
        /// </summary>
        public class EntityCollectionDemo
        {
            /// <summary>
            /// 基本模式,遍历EntityCollection
            /// </summary>
            public void Run(EntityCollection ec,IOrganizationService service)
            {
                if (ec != null && ec.Entities.Count > 0)
                {
                    foreach(Entity en in ec.Entities)
                    {
                        service.Delete(en.LogicalName, en.Id);
                    }
                }
            }

            /// <summary>
            /// 高速模式,遍历EntityCollection
            /// </summary>
            public void QuickRun(EntityCollection ec, IOrganizationService service)
            {
                ec.ReadMultiple(en => { service.Delete(en.LogicalName, en.Id); });
            }
        }

        /// <summary>
        /// 扩展方法
        /// </summary>
        public static class ExtensionFunction
        {
            public static void ReadMultiple(this EntityCollection ec,Action<Entity> action)
            {
                if (ec != null && ec.Entities.Count > 0)
                {
                    foreach (Entity en in ec.Entities)
                    {
                        action(en);
                    }
                }
            }
        }
    }

     

    对照:

查看全文
  • 相关阅读:
    Conntect Bluetooth devices in iOS.
    Why NSAttributedString import html must be on main thread?
    IOS7 SDK 几宗罪
    How to browse the entire documentation using XCode 5 Documentation and API Reference ?
    High Precision Timers in iOS / OS X
    [UWP]抄抄《CSS 故障艺术》的动画
    [Microsoft Teams]使用连接器接收Azure DevOps的通知
    [WPF 自定义控件]自定义一个“传统”的 Validation.ErrorTemplate
    [WPF 自定义控件]在MenuItem上使用RadioButton
    [WPF 自定义控件]创建包含CheckBox的ListBoxItem
  • 原文地址:https://www.cnblogs.com/ldxsuanfa/p/10799608.html
  • Copyright © 2011-2022 走看看