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


C# IEntityType.DisplayName方法代码示例

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


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

示例1: ValidateDiscriminator

 private void ValidateDiscriminator(IEntityType entityType)
 {
     if (entityType.ClrType?.IsInstantiable() ?? false)
     {
         var annotations = _relationalExtensions.For(entityType);
         if (annotations.DiscriminatorProperty == null)
         {
             ShowError(Relational.Internal.Strings.NoDiscriminatorProperty(entityType.DisplayName()));
         }
         if (annotations.DiscriminatorValue == null)
         {
             ShowError(Relational.Internal.Strings.NoDiscriminatorValue(entityType.DisplayName()));
         }
     }
 }
开发者ID:rbenhassine2,项目名称:EntityFramework,代码行数:15,代码来源:RelationalModelValidator.cs

示例2: StartTracking

        public virtual InternalEntityEntry StartTracking(
            IEntityType entityType, EntityKey entityKey, object entity, ValueBuffer valueBuffer)
        {
            if (entityKey == EntityKey.InvalidEntityKey)
            {
                throw new InvalidOperationException(Strings.InvalidPrimaryKey(entityType.DisplayName()));
            }

            var existingEntry = TryGetEntry(entityKey);

            if (existingEntry != null)
            {
                if (existingEntry.Entity != entity)
                {
                    throw new InvalidOperationException(Strings.IdentityConflict(entityType.DisplayName()));
                }

                return existingEntry;
            }

            var newEntry = _subscriber.SnapshotAndSubscribe(_factory.Create(this, entityType, entity, valueBuffer));

            _identityMap.Add(entityKey, newEntry);
            _entityReferenceMap[entity] = newEntry;

            newEntry.SetEntityState(EntityState.Unchanged);

            return newEntry;
        }
开发者ID:aishaloshik,项目名称:EntityFramework,代码行数:29,代码来源:StateManager.cs

示例3: GetEntity

        public virtual object GetEntity(
            IEntityType entityType,
            EntityKey entityKey,
            EntityLoadInfo entityLoadInfo,
            bool queryStateManager)
        {
            // hot path
            Debug.Assert(entityType != null);
            Debug.Assert(entityKey != null);

            if (entityKey == EntityKey.InvalidEntityKey)
            {
                throw new InvalidOperationException(
                    Strings.InvalidEntityKeyOnQuery(entityType.DisplayName()));
            }

            if (queryStateManager)
            {
                var entry = _stateManager.TryGetEntry(entityKey);

                if (entry != null)
                {
                    return entry.Entity;
                }
            }

            object entity;

            WeakReference<object> weakReference;
            if (!_identityMap.TryGetValue(entityKey, out weakReference)
                || !weakReference.TryGetTarget(out entity))
            {
                entity = entityLoadInfo.Materialize();

                if (weakReference != null)
                {
                    weakReference.SetTarget(entity);
                }
                else
                {
                    GarbageCollectIdentityMap();

                    _identityMap.Add(entityKey, new WeakReference<object>(entity));
                }

                _valueBuffers.Add(entity, entityLoadInfo.ValueBuffer);
            }

            return entity;
        }
开发者ID:JamesWang007,项目名称:EntityFramework,代码行数:50,代码来源:QueryBuffer.cs

示例4: EnsureClrInheritance

        private void EnsureClrInheritance(IModel model, IEntityType entityType, HashSet<IEntityType> validEntityTypes)
        {
            if (validEntityTypes.Contains(entityType))
            {
                return;
            }

            var baseClrType = entityType.ClrType?.GetTypeInfo().BaseType;
            while (baseClrType != null)
            {
                var baseEntityType = model.FindEntityType(baseClrType);
                if (baseEntityType != null)
                {
                    if (!baseEntityType.IsAssignableFrom(entityType))
                    {
                        ShowError(CoreStrings.InconsistentInheritance(entityType.DisplayName(), baseEntityType.DisplayName()));
                    }
                    EnsureClrInheritance(model, baseEntityType, validEntityTypes);
                    break;
                }
                baseClrType = baseClrType.GetTypeInfo().BaseType;
            }

            if (entityType.ClrType?.IsInstantiable() == false
                && !entityType.GetDerivedTypes().Any())
            {
                ShowError(CoreStrings.AbstractLeafEntityType(entityType.DisplayName()));
            }

            validEntityTypes.Add(entityType);
        }
开发者ID:RickyLin,项目名称:EntityFramework,代码行数:31,代码来源:ModelValidator.cs

示例5: StartTracking

        public virtual InternalEntityEntry StartTracking(IEntityType entityType, object entity, IValueReader valueReader)
        {
            // TODO: Perf: Pre-compute this for speed
            var keyProperties = entityType.GetPrimaryKey().Properties;
            var keyValue = _keyFactorySource.GetKeyFactory(keyProperties).Create(entityType, keyProperties, valueReader);

            if (keyValue == EntityKey.InvalidEntityKey)
            {
                throw new InvalidOperationException(Strings.InvalidPrimaryKey(entityType.DisplayName()));
            }

            var existingEntry = TryGetEntry(keyValue);

            if (existingEntry != null)
            {
                if (existingEntry.Entity != entity)
                {
                    throw new InvalidOperationException(Strings.IdentityConflict(entityType.DisplayName()));
                }

                return existingEntry;
            }

            var newEntry = _subscriber.SnapshotAndSubscribe(_factory.Create(this, entityType, entity, valueReader));

            _identityMap.Add(keyValue, newEntry);
            _entityReferenceMap[entity] = newEntry;

            newEntry.SetEntityState(EntityState.Unchanged);

            return newEntry;
        }
开发者ID:thegido,项目名称:EntityFramework,代码行数:32,代码来源:StateManager.cs

示例6: ValidateDiscriminator

 private void ValidateDiscriminator(IEntityType entityType)
 {
     var annotations = RelationalExtensions.For(entityType);
     if (annotations.DiscriminatorProperty == null)
     {
         ShowError(RelationalStrings.NoDiscriminatorProperty(entityType.DisplayName()));
     }
     if (annotations.DiscriminatorValue == null)
     {
         ShowError(RelationalStrings.NoDiscriminatorValue(entityType.DisplayName()));
     }
 }
开发者ID:RickyLin,项目名称:EntityFramework,代码行数:12,代码来源:RelationalModelValidator.cs

示例7: AsINotifyCollectionChanged

        private static INotifyCollectionChanged AsINotifyCollectionChanged(
            InternalEntityEntry entry,
            INavigation navigation,
            IEntityType entityType,
            ChangeTrackingStrategy changeTrackingStrategy)
        {
            var notifyingCollection = navigation.GetCollectionAccessor().GetOrCreate(entry.Entity) as INotifyCollectionChanged;
            if (notifyingCollection == null)
            {
                throw new InvalidOperationException(
                    CoreStrings.NonNotifyingCollection(navigation.Name, entityType.DisplayName(), changeTrackingStrategy));
            }

            return notifyingCollection;
        }
开发者ID:RickyLin,项目名称:EntityFramework,代码行数:15,代码来源:InternalEntityEntrySubscriber.cs

示例8: AsINotifyPropertyChanging

        private static INotifyPropertyChanging AsINotifyPropertyChanging(
            InternalEntityEntry entry,
            IEntityType entityType,
            ChangeTrackingStrategy changeTrackingStrategy)
        {
            var changing = entry.Entity as INotifyPropertyChanging;
            if (changing == null)
            {
                throw new InvalidOperationException(
                    CoreStrings.ChangeTrackingInterfaceMissing(
                        entityType.DisplayName(), changeTrackingStrategy, typeof(INotifyPropertyChanging).Name));
            }

            return changing;
        }
开发者ID:RickyLin,项目名称:EntityFramework,代码行数:15,代码来源:InternalEntityEntrySubscriber.cs

示例9: CreateName

 public virtual string CreateName(IEntityType entityType)
     => _shouldPluralize ? entityType.DisplayName().Pluralize() : entityType.DisplayName();
开发者ID:Grinderofl,项目名称:FluentModelBuilder,代码行数:2,代码来源:PluralizingTableNameGenerator.cs

示例10: StartTracking

        public virtual InternalEntityEntry StartTracking(
            IEntityType entityType, IKeyValue keyValue, object entity, ValueBuffer valueBuffer)
        {
            if (keyValue == KeyValue.InvalidKeyValue)
            {
                throw new InvalidOperationException(CoreStrings.InvalidPrimaryKey(entityType.DisplayName()));
            }

            var existingEntry = TryGetEntry(keyValue);
            if (existingEntry != null)
            {
                if (existingEntry.Entity != entity)
                {
                    throw new InvalidOperationException(CoreStrings.IdentityConflict(entityType.DisplayName()));
                }

                return existingEntry;
            }

            var newEntry = _subscriber.SnapshotAndSubscribe(_factory.Create(this, entityType, entity, valueBuffer), valueBuffer);

            AddToIdentityMap(entityType, keyValue, newEntry);

            _entityReferenceMap[entity] = newEntry;
            _detachedEntityReferenceMap.Remove(entity);

            newEntry.SetEntityState(EntityState.Unchanged);

            return newEntry;
        }
开发者ID:adwardliu,项目名称:EntityFramework,代码行数:30,代码来源:StateManager.cs

示例11: CreateMaterializeExpression

        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used 
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public virtual Expression CreateMaterializeExpression(
            IEntityType entityType,
            Expression valueBufferExpression,
            int[] indexMap = null)
        {
            // ReSharper disable once SuspiciousTypeConversion.Global
            var materializer = entityType as IEntityMaterializer;

            if (materializer != null)
            {
                return Expression.Call(
                    Expression.Constant(materializer),
                    ((Func<ValueBuffer, object>)materializer.CreateEntity).GetMethodInfo(),
                    valueBufferExpression);
            }

            if (!entityType.HasClrType())
            {
                throw new InvalidOperationException(CoreStrings.NoClrType(entityType.Name));
            }

            if (entityType.IsAbstract())
            {
                throw new InvalidOperationException(CoreStrings.CannotMaterializeAbstractType(entityType));
            }

            var constructorInfo = entityType.ClrType.GetDeclaredConstructor(null);

            if (constructorInfo == null)
            {
                throw new InvalidOperationException(CoreStrings.NoParameterlessConstructor(entityType.DisplayName()));
            }

            var instanceVariable = Expression.Variable(entityType.ClrType, "instance");

            var blockExpressions
                = new List<Expression>
                {
                    Expression.Assign(
                        instanceVariable,
                        Expression.New(constructorInfo))
                };

            blockExpressions.AddRange(
                from mapping in _memberMapper.MapPropertiesToMembers(entityType)
                let propertyInfo = mapping.Item2 as PropertyInfo
                let targetMember
                    = propertyInfo != null
                        ? Expression.Property(instanceVariable, propertyInfo)
                        : Expression.Field(instanceVariable, (FieldInfo)mapping.Item2)
                select
                    Expression.Assign(
                        targetMember,
                        CreateReadValueExpression(
                            valueBufferExpression,
                            targetMember.Type,
                            indexMap?[mapping.Item1.GetIndex()] ?? mapping.Item1.GetIndex())));

            blockExpressions.Add(instanceVariable);

            return Expression.Block(new[] { instanceVariable }, blockExpressions);
        }
开发者ID:ymd1223,项目名称:EntityFramework,代码行数:66,代码来源:EntityMaterializerSource.cs


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