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


C# EntityTypeConfiguration类代码示例

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


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

示例1: Apply

        /// <summary>
        /// Figures out the key properties and marks them as Keys in the EDM model.
        /// </summary>
        /// <param name="entity">The entity type being configured.</param>
        /// <param name="model">The <see cref="ODataModelBuilder"/>.</param>
        public override void Apply(EntityTypeConfiguration entity, ODataConventionModelBuilder model)
        {
            if (entity == null)
            {
                throw Error.ArgumentNull("entity");
            }

            // Suppress the EntityKeyConvention if there is any key in EntityTypeConfiguration.
            if (entity.Keys.Any() || entity.EnumKeys.Any())
            {
                return;
            }

            // Suppress the EntityKeyConvention if base type has any key.
            if (entity.BaseType != null && entity.BaseType.Keys().Any())
            {
                return;
            }

            PropertyConfiguration key = GetKeyProperty(entity);
            if (key != null)
            {
                entity.HasKey(key.PropertyInfo);
            }
        }
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:30,代码来源:EntityKeyConvention.cs

示例2: NhsContext

 public NhsContext(EntityTypeConfiguration<Person> personTypeConfiguration,
     EntityTypeConfiguration<Colour> colourTypeConfiguration)
     : base("name=NhsContext")
 {
     _personTypeConfiguration = personTypeConfiguration;
     _colourTypeConfiguration = colourTypeConfiguration;
 }
开发者ID:jerzynaf,项目名称:WebApiTestFirstTry,代码行数:7,代码来源:NhsContext.cs

示例3: RegTo

 public void RegTo(ConfigurationRegistrar confRegistrar)
 {
     var r = new EntityTypeConfiguration<UserInfo>();
     r.ToTable("UserInfo");
     r.HasKey(p => p.AutoId);
     confRegistrar.Add<UserInfo>(r);
 }
开发者ID:EricOrYhj,项目名称:PinEveryThing,代码行数:7,代码来源:UserMap.cs

示例4: Apply

 public override void Apply(EntityTypeConfiguration entity, ODataModelBuilder model)
 {
     if (entity.IsAbstract == null)
     {
         entity.IsAbstract = entity.ClrType.IsAbstract;
     }
 }
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:7,代码来源:AbstractEntityTypeDiscoveryConvention.cs

示例5: Can_get_and_set_table_name

        public void Can_get_and_set_table_name()
        {
            var entityTypeConfiguration = new EntityTypeConfiguration(typeof(object));
            entityTypeConfiguration.ToTable("Foo");

            Assert.Equal("Foo", entityTypeConfiguration.GetTableName().Name);
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:7,代码来源:EntityTypeConfigurationTests.cs

示例6: GetDefaultNavigationSource

        private static NavigationSourceConfiguration GetDefaultNavigationSource(EntityTypeConfiguration targetEntityType,
            ODataModelBuilder model, bool isSingleton)
        {
            if (targetEntityType == null)
            {
                return null;
            }

            NavigationSourceConfiguration[] matchingNavigationSources = null;
            if (isSingleton)
            {
                matchingNavigationSources = model.Singletons.Where(e => e.EntityType == targetEntityType).ToArray();
            }
            else
            {
                matchingNavigationSources = model.EntitySets.Where(e => e.EntityType == targetEntityType).ToArray();
            }

            if (matchingNavigationSources.Length > 1)
            {
                return null;
            }
            else if (matchingNavigationSources.Length == 1)
            {
                return matchingNavigationSources[0];
            }
            else
            {
                // default navigation source is the same as the default navigation source for the base type.
                return GetDefaultNavigationSource(targetEntityType.BaseType as EntityTypeConfiguration,
                    model, isSingleton);
            }
        }
开发者ID:ahmetgoktas,项目名称:aspnetwebstack,代码行数:33,代码来源:AssociationSetDiscoveryConvention.cs

示例7: ExpressionTranslator

        /// <summary>
        ///     Constructor.
        /// </summary>
        /// <param name="nameChanges"></param>
        internal ExpressionTranslator(EntityTypeConfiguration configuration)
        {
            //_nameChanges = nameChanges;
            _configuration = configuration;
            _nameChanges = configuration.KeyMappings;

            _constantEvaluator = new ExpressionEvaluator();
        }
开发者ID:s-innovations,项目名称:azure-table-storage-repository-pattern,代码行数:12,代码来源:ExpressionTranslator.cs

示例8: MapApiDataSource

 /// <summary>Defines the mapping information for the entity 'ApiDataSource'</summary>
 /// <param name="config">The configuration to modify.</param>
 protected virtual void MapApiDataSource(EntityTypeConfiguration<ApiDataSource> config)
 {
     config.ToTable("ApiDataSource");
     config.HasKey(t => t.Id);
     config.Property(t => t.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
     config.Property(t => t.SourceName).HasMaxLength(50).IsRequired();
     config.Property(t => t.SourceBaseUrl).HasMaxLength(200);
 }
开发者ID:justinrobinson,项目名称:ODataTest,代码行数:10,代码来源:SqlExpressNovemberModelBuilder.cs

示例9: Configure_should_throw_when_property_not_found

        public void Configure_should_throw_when_property_not_found()
        {
            var entityType = new EdmEntityType { Name = "E" };
            var entityTypeConfiguration = new EntityTypeConfiguration(typeof(object));
            var mockPropertyConfiguration = new Mock<PrimitivePropertyConfiguration>();
            entityTypeConfiguration.Property(new PropertyPath(new MockPropertyInfo()), () => mockPropertyConfiguration.Object);

            Assert.Equal(Strings.PropertyNotFound(("P"), "E"), Assert.Throws<InvalidOperationException>(() => entityTypeConfiguration.Configure(entityType, new EdmModel())).Message);
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:9,代码来源:EntityTypeConfigurationTests.cs

示例10: Add_entity_configuration_should_add_to_model_configuration

        public void Add_entity_configuration_should_add_to_model_configuration()
        {
            var modelConfiguration = new ModelConfiguration();
            var entityConfiguration = new EntityTypeConfiguration<object>();

            new ConfigurationRegistrar(modelConfiguration).Add(entityConfiguration);

            Assert.Same(entityConfiguration.Configuration, modelConfiguration.Entity(typeof(object)));
        }
开发者ID:jwanagel,项目名称:jjwtest,代码行数:9,代码来源:ConfigurationRegistrarTests.cs

示例11: Configure_should_set_configuration

        public void Configure_should_set_configuration()
        {
            var entityType = new EdmEntityType { Name = "E" };
            var entityTypeConfiguration = new EntityTypeConfiguration(typeof(object));

            entityTypeConfiguration.Configure(entityType, new EdmModel());

            Assert.Same(entityTypeConfiguration, entityType.GetConfiguration());
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:9,代码来源:EntityTypeConfigurationTests.cs

示例12: GetTableName_returns_current_TableName

        public void GetTableName_returns_current_TableName()
        {
            var entityTypeConfiguration = new EntityTypeConfiguration(typeof(object));

            Assert.Equal(null, entityTypeConfiguration.GetTableName());

            entityTypeConfiguration.ToTable("Foo");
            Assert.Equal("Foo", entityTypeConfiguration.GetTableName().Name);
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:9,代码来源:EntityTypeConfigurationTests.cs

示例13: Define

        internal static void Define(EntityTypeConfiguration<Domain.Transaction> config)
        {
            config.HasOptional(p => p.CreditedUser)
                .WithMany(r => r.Credits)
                .HasForeignKey(fk => fk.CreditedUserId);

            config.HasOptional(p => p.DebitedUser)
                .WithMany(r => r.Debits)
                .HasForeignKey(fk => fk.DebitedUserId);

            config.Property(p => p.Amount).HasPrecision(19, 4);
        }
开发者ID:RichardAllanBrown,项目名称:OctoBotSharp,代码行数:12,代码来源:TransactionMap.cs

示例14: Define

        internal static void Define(EntityTypeConfiguration<Domain.ItemInstance> config)
        {
            config.HasRequired(r => r.Item)
                .WithMany(r => r.OwnedBy)
                .HasForeignKey(fk => fk.ItemId)
                .WillCascadeOnDelete(false);

            config.HasRequired(r => r.Owner)
                .WithMany(r => r.Items)
                .HasForeignKey(fk => fk.OwnerId)
                .WillCascadeOnDelete(false);
        }
开发者ID:RichardAllanBrown,项目名称:OctoBotSharp,代码行数:12,代码来源:ItemInstanceMap.cs

示例15: MapMovieNotFound

 /// <summary>Defines the mapping information for the entity 'MovieNotFound'</summary>
 /// <param name="config">The configuration to modify.</param>
 protected virtual void MapMovieNotFound(EntityTypeConfiguration<MovieNotFound> config)
 {
     config.ToTable("MovieNotFound");
     config.HasKey(t => new { t.ItemId, t.ItemSource });
     config.Property(t => t.ItemId).HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
     config.Property(t => t.ItemSource).HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
     config.Property(t => t.RowId).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity).IsRequired();
     config.Property(t => t.ItemSearchTitle).HasMaxLength(100);
     config.Property(t => t.ItemSearchYear);
     config.Property(t => t.AddedOn);
     config.Property(t => t.ChangedOn);
 }
开发者ID:justinrobinson,项目名称:ODataTest,代码行数:14,代码来源:SqlExpressNovemberModelBuilder.cs


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