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


C# EntityEntry.UpdateComplexObjectSnapshot方法代码示例

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


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

示例1: SetCurrentValue

        // See IChangeTrackingStrategy documentation
        public void SetCurrentValue(EntityEntry entry, StateManagerMemberMetadata member, int ordinal, object target, object value)
        {
            // If the target is the entity, then this is a change to a member on the entity itself rather than
            // a change to some complex type property defined on the entity.  In this case we can use the change tracking
            // API in the normal way.
            if (ReferenceEquals(target, entry.Entity))
            {
                // equivalent of EntityObject.ReportPropertyChanging()
                ((IEntityChangeTracker)entry).EntityMemberChanging(member.CLayerName);
                member.SetValue(target, value);
                // equivalent of EntityObject.ReportPropertyChanged()
                ((IEntityChangeTracker)entry).EntityMemberChanged(member.CLayerName);

                if (member.IsComplex)
                {
                    // This is required because the OSE contains a separate cache of user objects for
                    // complex objects such that original values can be looked up correctly.
                    entry.UpdateComplexObjectSnapshot(member, target, ordinal, value);
                }
            }
            else
            {
                // Must be a complex type.  We would like to do this:
                // ((IEntityChangeTracker)entry).EntityComplexMemberChanging(topLevelMember.CLayerName, target, member.CLayerName);
                // ((IEntityChangeTracker)entry).EntityComplexMemberChanged(topLevelMember.CLayerName, target, member.CLayerName);
                //
                // However, we have no way of getting the topLevelMember.CLayerName.  This is because the value record does not
                // contain any reference to its parent.  (In non-POCO, ComplexObject takes care of this.)
                // Therefore, in this case we are going to just call a localized DetectChanges to make sure that changes in the
                // complex types are found.
                //
                // Note that this case only happens when the entity is POCO and complex types are set through the CurrentValues
                // object.  This is probably not a very common pattern.
                member.SetValue(target, value);
                if (entry.State
                    != EntityState.Added)
                {
                    // Entry is not Detached - checked in ValidateState() in EntityEntry.SetCurrentEntityValue
                    entry.DetectChangesInProperties(true);
                }
            }
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:43,代码来源:SnapshotChangeTrackingStrategy.cs


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