当前位置: 首页>>代码示例>>C#>>正文


C# EntityBase.GetUpdateStrategyForDuplicateDates方法代码示例

本文整理汇总了C#中EntityBase.GetUpdateStrategyForDuplicateDates方法的典型用法代码示例。如果您正苦于以下问题:C# EntityBase.GetUpdateStrategyForDuplicateDates方法的具体用法?C# EntityBase.GetUpdateStrategyForDuplicateDates怎么用?C# EntityBase.GetUpdateStrategyForDuplicateDates使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EntityBase的用法示例。


在下文中一共展示了EntityBase.GetUpdateStrategyForDuplicateDates方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PerformUpdate

        /// <summary>
        /// Given the provided strategies, manipulate all entities to correct any violations
        /// of the current policy. If no strategies are provided, the policy's default
        /// strategies are used. An exception is thrown if the provided strategies are not
        /// valid for the current policy.
        /// </summary>
        /// <param name="Item">The item.</param>
        /// <param name="Entity">The entity.</param>
        /// <param name="PreferredUpdateStrategy">The preferred update strategy.</param>
        /// <param name="PreferredUpdateStrategyForDuplicateDates">The preferred update strategy for duplicate dates.</param>
        /// <exception cref="System.ArgumentNullException"></exception>
        /// <exception cref="System.InvalidOperationException">
        /// The requested strategy is not available for this policy.
        /// or
        /// The requested strategy is not available for this policy.
        /// </exception>
        public void PerformUpdate(Item Item, EntityBase Entity, IUpdateStrategy PreferredUpdateStrategy = null, IUpdateStrategy PreferredUpdateStrategyForDuplicateDates = null)
        {
            if (Item == null)
            {
                throw new ArgumentNullException(nameof(Item));
            }
            if (Entity == null)
            {
                throw new ArgumentNullException(nameof(Entity));
            }

            IUpdateStrategy Strategy = Entity.GetUpdateStrategy();
            IUpdateStrategy StrategyForDuplicateDates = Entity.GetUpdateStrategyForDuplicateDates();

            if (PreferredUpdateStrategy != null)
            {
                if (!Entity.GetUpdatePolicy().GetAvailableStrategies().Any(s => s.GetType() == PreferredUpdateStrategy.GetType()))
                {
                    throw new InvalidOperationException("The requested strategy is not available for this policy.");
                }

                Strategy = PreferredUpdateStrategy;
            }

            if (PreferredUpdateStrategyForDuplicateDates != null)
            {
                if (!Entity.GetUpdatePolicy().GetAvailableStrategies().Any(s => s.GetType() == PreferredUpdateStrategyForDuplicateDates.GetType()))
                {
                    throw new InvalidOperationException("The requested strategy is not available for this policy.");
                }

                StrategyForDuplicateDates = PreferredUpdateStrategyForDuplicateDates;
            }

            var AllEntities = Item.AllEntities.ToArray();
            for (int i = 0; i < AllEntities.Count(); i++)
            {
                var OtherEntity = AllEntities.ElementAt(i);

                if (OtherEntity.EffectiveDate == Entity.EffectiveDate && OtherEntity.EndEffectiveDate == Entity.EndEffectiveDate)
                {
                    StrategyForDuplicateDates.PerformUpdate(OtherEntity, Entity);
                }
                else
                {
                    Strategy.PerformUpdate(OtherEntity, Entity);
                }
            }
        }
开发者ID:emisaacson,项目名称:EffectFramework,代码行数:65,代码来源:UpdatePolicy.cs


注:本文中的EntityBase.GetUpdateStrategyForDuplicateDates方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。