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


C# Internal.InternalEntityEntry类代码示例

本文整理汇总了C#中Microsoft.Data.Entity.ChangeTracking.Internal.InternalEntityEntry的典型用法代码示例。如果您正苦于以下问题:C# InternalEntityEntry类的具体用法?C# InternalEntityEntry怎么用?C# InternalEntityEntry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


InternalEntityEntry类属于Microsoft.Data.Entity.ChangeTracking.Internal命名空间,在下文中一共展示了InternalEntityEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AttachGraph

 public virtual void AttachGraph(InternalEntityEntry rootEntry, EntityState entityState)
     => _graphIterator.TraverseGraph(
         new EntityEntryGraphNode(rootEntry, null)
             {
                 NodeState = entityState
             },
         PaintAction);
开发者ID:adwardliu,项目名称:EntityFramework,代码行数:7,代码来源:EntityGraphAttacher.cs

示例2: Generate

        public virtual void Generate(InternalEntityEntry entry)
        {
            foreach (var property in entry.EntityType.GetProperties())
            {
                var isForeignKey = property.IsForeignKey(entry.EntityType);

                if ((property.RequiresValueGenerator || isForeignKey)
                    && property.IsSentinelValue(entry[property]))
                {
                    if (isForeignKey)
                    {
                        _keyPropagator.PropagateValue(entry, property);
                    }
                    else
                    {
                        var valueGenerator = _valueGeneratorSelector.Select(property, entry.EntityType);

                        Debug.Assert(valueGenerator != null);

                        var generatedValue = valueGenerator.NextSkippingSentinel(property);
                        SetGeneratedValue(entry, property, generatedValue, valueGenerator.GeneratesTemporaryValues);
                    }
                }
            }
        }
开发者ID:491134648,项目名称:EntityFramework,代码行数:25,代码来源:ValueGenerationManager.cs

示例3: Generate

        public virtual void Generate(InternalEntityEntry entry)
        {
            foreach (var property in entry.EntityType.GetProperties())
            {
                var isForeignKey = property.IsForeignKey(entry.EntityType);

                if ((property.RequiresValueGenerator || isForeignKey)
                    && property.ClrType.IsDefaultValue(entry[property]))
                {
                    if (isForeignKey)
                    {
                        _keyPropagator.PropagateValue(entry, property);
                    }
                    else
                    {
                        var valueGenerator = _valueGeneratorSelector.Select(property, property.IsKey()
                            ? property.DeclaringEntityType
                            : entry.EntityType);

                        Debug.Assert(valueGenerator != null);

                        SetGeneratedValue(entry, property, valueGenerator.Next(), valueGenerator.GeneratesTemporaryValues);
                    }
                }
            }
        }
开发者ID:adwardliu,项目名称:EntityFramework,代码行数:26,代码来源:ValueGenerationManager.cs

示例4: ForeignKeyPropertyChangedAction

        private void ForeignKeyPropertyChangedAction(InternalEntityEntry entry, IProperty property, object oldValue, object newValue)
        {
            foreach (var foreignKey in entry.EntityType.GetForeignKeys().Where(p => p.Properties.Contains(property)).Distinct())
            {
                var navigations = _model.GetNavigations(foreignKey).ToList();

                var oldPrincipalEntry = entry.StateManager.GetPrincipal(entry.RelationshipsSnapshot, foreignKey);
                if (oldPrincipalEntry != null)
                {
                    Unfixup(navigations, oldPrincipalEntry, entry);
                }

                var principalEntry = entry.StateManager.GetPrincipal(entry, foreignKey);
                if (principalEntry != null)
                {
                    if (foreignKey.IsUnique)
                    {
                        var oldDependents = entry.StateManager.GetDependents(principalEntry, foreignKey).Where(e => e != entry).ToList();

                        // TODO: Decide how to handle case where multiple values found (negative case)
                        // Issue #739
                        if (oldDependents.Count > 0)
                        {
                            StealReference(foreignKey, oldDependents[0]);
                        }
                    }

                    DoFixup(navigations, principalEntry, new[] { entry });
                }
            }
        }
开发者ID:aishaloshik,项目名称:EntityFramework,代码行数:31,代码来源:NavigationFixer.cs

示例5: BindMixins

        /// <summary>
        /// Binds the mixins to the entity through change tracking.
        /// </summary>
        /// <param name="entry">The entity entry.</param>
        /// <param name="entityType">The entity type.</param>
        /// <param name="entity">The entity instance.</param>
        private void BindMixins(InternalEntityEntry entry, IEntityType entityType, object entity)
        {
            var mixinHost = entity as ISupportMixins;
            if (mixinHost != null)
            {
                var mixinTypes = entityType
                    .Annotations
                    .Where(a => a.Name == "MixinType")
                    .Select(a => (Type)a.Value)
                    .Distinct()
                    .ToArray();

                foreach (var mixinType in mixinTypes)
                {
                    // Create the mixin.
                    var mixin = (Mixin)Activator.CreateInstance(mixinType);

                    // Set the resolver.
                    mixin.SetPropertyEntryResolver(p => new PropertyEntry(entry, p));

                    // Assign to the host entity.
                    mixinHost.AddMixin(mixin);
                }
            }
        }
开发者ID:Antaris,项目名称:EntityFrameworkMixins,代码行数:31,代码来源:InternalEntityEntryFactory.cs

示例6: PropertyEntry

        /// <summary>
        ///     Initializes a new instance of the <see cref="PropertyEntry" /> class. Instances of this class
        ///     are returned from methods when using the <see cref="ChangeTracker" /> API and it is not designed
        ///     to be directly constructed in your application code.
        /// </summary>
        /// <param name="internalEntry">  The internal entry tracking information about the entity the property belongs to. </param>
        /// <param name="name"> The name of the property. </param>
        public PropertyEntry([NotNull] InternalEntityEntry internalEntry, [NotNull] string name)
        {
            Check.NotNull(internalEntry, nameof(internalEntry));
            Check.NotEmpty(name, nameof(name));

            _internalEntry = internalEntry;
            Metadata = internalEntry.EntityType.GetProperty(name);
        }
开发者ID:491134648,项目名称:EntityFramework,代码行数:15,代码来源:PropertyEntry.cs

示例7: GetProperties

        private static IEnumerable<IPropertyBase> GetProperties(InternalEntityEntry entry)
        {
            var entityType = entry.EntityType;

            return entityType.GetKeys().SelectMany(k => k.Properties)
                .Concat(entityType.GetForeignKeys().SelectMany(fk => fk.Properties))
                .Distinct()
                .Concat<IPropertyBase>(entityType.GetNavigations());
        }
开发者ID:adwardliu,项目名称:EntityFramework,代码行数:9,代码来源:RelationshipsSnapshot.cs

示例8: CreateSidecar

        protected override Sidecar CreateSidecar(InternalEntityEntry entry = null)
        {
            entry = entry ?? CreateInternalEntry();
            var properties = entry.EntityType.GetPrimaryKey().Properties
                .Concat(entry.EntityType.GetForeignKeys().SelectMany(fk => fk.Properties))
                .ToList();

            return new StoreGeneratedValuesFactory().Create(entry, properties);
        }
开发者ID:thegido,项目名称:EntityFramework,代码行数:9,代码来源:StoreGeneratedValuesTest.cs

示例9: SnapshotAndSubscribe

        public virtual InternalEntityEntry SnapshotAndSubscribe(InternalEntityEntry entry, ValueBuffer? values)
        {
            var entityType = entry.EntityType;

            if (entityType.UseEagerSnapshots())
            {
                if (values != null)
                {
                    entry.OriginalValues = new ValueBufferOriginalValues(entry, values.Value);
                }
                else
                {
                    entry.OriginalValues.TakeSnapshot();
                }

                entry.RelationshipsSnapshot.TakeSnapshot();
            }
            else
            {
                foreach (var navigation in entityType.GetNavigations().Where(n => n.IsNonNotifyingCollection(entry)))
                {
                    entry.RelationshipsSnapshot.TakeSnapshot(navigation);
                }
            }

            var changing = entry.Entity as INotifyPropertyChanging;
            if (changing != null)
            {
                changing.PropertyChanging += (s, e) =>
                    {
                        var property = TryGetPropertyBase(entityType, e.PropertyName);
                        if (property != null)
                        {
                            _notifier.PropertyChanging(entry, property);
                        }
                    };
            }

            var changed = entry.Entity as INotifyPropertyChanged;
            if (changed != null)
            {
                changed.PropertyChanged += (s, e) =>
                    {
                        var property = TryGetPropertyBase(entityType, e.PropertyName);
                        if (property != null)
                        {
                            _notifier.PropertyChanged(entry, property);
                        }
                    };
            }

            return entry;
        }
开发者ID:491134648,项目名称:EntityFramework,代码行数:53,代码来源:InternalEntityEntrySubscriber.cs

示例10: SetGeneratedValue

        private static void SetGeneratedValue(InternalEntityEntry entry, IProperty property, object generatedValue, bool isTemporary)
        {
            if (generatedValue != null)
            {
                entry[property] = generatedValue;

                if (isTemporary)
                {
                    entry.MarkAsTemporary(property);
                }
            }
        }
开发者ID:thegido,项目名称:EntityFramework,代码行数:12,代码来源:ValueGenerationManager.cs

示例11: PropertyEntry

        /// <summary>
        ///     <para>
        ///         Initializes a new instance of the <see cref="PropertyEntry" /> class.
        ///     </para>
        ///     <para>
        ///         Instances of this class are returned from methods when using the <see cref="ChangeTracker" /> API and it is
        ///         not designed to be directly constructed in your application code.
        ///     </para>
        /// </summary>
        /// <param name="internalEntry">  The internal entry tracking information about the entity the property belongs to. </param>
        /// <param name="name"> The name of the property. </param>
        public PropertyEntry([NotNull] InternalEntityEntry internalEntry, [NotNull] string name)
        {
            Check.NotNull(internalEntry, nameof(internalEntry));
            Check.NotEmpty(name, nameof(name));

            _internalEntry = internalEntry;
            var property = internalEntry.EntityType.FindProperty(name);
            if (property == null)
            {
                throw new InvalidOperationException(CoreStrings.PropertyNotFound(name, internalEntry.EntityType.DisplayName()));
            }
            Metadata = property;
        }
开发者ID:adwardliu,项目名称:EntityFramework,代码行数:24,代码来源:PropertyEntry.cs

示例12: NavigationReferenceChangedAction

        private void NavigationReferenceChangedAction(InternalEntityEntry entry, INavigation navigation, object oldValue, object newValue)
        {
            var foreignKey = navigation.ForeignKey;
            var dependentProperties = foreignKey.Properties;
            var principalProperties = foreignKey.PrincipalKey.Properties;

            // TODO: What if the other entry is not yet being tracked?
            // Issue #323
            if (navigation.PointsToPrincipal())
            {
                if (newValue != null)
                {
                    SetForeignKeyValue(foreignKey, entry, entry.StateManager.GetOrCreateEntry(newValue));
                }
                else
                {
                    SetNullForeignKey(entry, dependentProperties);
                }
            }
            else
            {
                Debug.Assert(foreignKey.IsUnique);

                if (newValue != null)
                {
                    var dependentEntry = entry.StateManager.GetOrCreateEntry(newValue);

                    // Avoid eagerly setting FKs (which may be PKs) in un-tracked entities so as not to mess up
                    // Attach behavior that is based on key values.
                    if (dependentEntry.EntityState != EntityState.Detached)
                    {
                        SetForeignKeyValue(foreignKey, dependentEntry, entry);
                    }
                }

                if (oldValue != null)
                {
                    ConditionallySetNullForeignKey(entry.StateManager.GetOrCreateEntry(oldValue), dependentProperties, entry, principalProperties);
                }
            }

            if (oldValue != null)
            {
                ConditionallyClearInverse(entry, navigation, oldValue);
            }

            if (newValue != null)
            {
                SetInverse(entry, navigation, newValue);
            }
        }
开发者ID:aishaloshik,项目名称:EntityFramework,代码行数:51,代码来源:NavigationFixer.cs

示例13: PropagateValue

        public virtual void PropagateValue(InternalEntityEntry entry, IProperty property)
        {
            Debug.Assert(property.IsForeignKey());

            if (!TryPropagateValue(entry, property)
                && property.IsKey())
            {
                var valueGenerator = TryGetValueGenerator(property);

                if (valueGenerator != null)
                {
                    entry[property] = valueGenerator.Next();
                }
            }
        }
开发者ID:aishaloshik,项目名称:EntityFramework,代码行数:15,代码来源:KeyPropagator.cs

示例14: TryPropagateValue

        private bool TryPropagateValue(InternalEntityEntry entry, IProperty property)
        {
            var entityType = property.EntityType;
            var stateManager = entry.StateManager;

            foreach (var foreignKey in entityType.GetForeignKeys())
            {
                for (var propertyIndex = 0; propertyIndex < foreignKey.Properties.Count; propertyIndex++)
                {
                    if (property == foreignKey.Properties[propertyIndex])
                    {
                        object valueToPropagte = null;

                        foreach (var navigation in entityType.GetNavigations()
                            .Concat(foreignKey.PrincipalEntityType.GetNavigations())
                            .Where(n => n.ForeignKey == foreignKey)
                            .Distinct())
                        {
                            var principal = TryFindPrincipal(stateManager, navigation, entry.Entity);

                            if (principal != null)
                            {
                                var principalEntry = stateManager.GetOrCreateEntry(principal);
                                var principalProperty = foreignKey.PrincipalKey.Properties[propertyIndex];

                                var principalValue = principalEntry[principalProperty];
                                if (!principalProperty.IsSentinelValue(principalValue))
                                {
                                    valueToPropagte = principalValue;
                                    break;
                                }
                            }
                        }

                        if (valueToPropagte != null)
                        {
                            entry[property] = valueToPropagte;
                            return true;
                        }
                    }
                }
            }

            return false;
        }
开发者ID:aishaloshik,项目名称:EntityFramework,代码行数:45,代码来源:KeyPropagator.cs

示例15: PropertyChanging

        public virtual void PropertyChanging(InternalEntityEntry entry, IPropertyBase propertyBase)
        {
            if (!entry.EntityType.UseEagerSnapshots())
            {
                var property = propertyBase as IProperty;
                if (property != null
                    && property.GetOriginalValueIndex() >= 0)
                {
                    entry.OriginalValues.EnsureSnapshot(property);
                }

                var navigation = propertyBase as INavigation;
                if ((navigation != null && !navigation.IsCollection())
                    || (property != null && (property.IsKey() || property.IsForeignKey(entry.EntityType))))
                {
                    // TODO: Consider making snapshot temporary here since it is no longer required after PropertyChanged is called
                    // See issue #730
                    entry.RelationshipsSnapshot.TakeSnapshot(propertyBase);
                }
            }
        }
开发者ID:adwardliu,项目名称:EntityFramework,代码行数:21,代码来源:ChangeDetector.cs


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