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


C# EntityTypeConfiguration.ToTable方法代码示例

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


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

示例1: Apply_should_not_set_table_name_when_already_set

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

            new TableAttributeConvention.TableAttributeConventionImpl()
                .Apply(new MockType(), entityTypeConfiguration, new TableAttribute("Foo"));

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

示例2: ToTable_with_schema_is_noop_when_set

        public void ToTable_with_schema_is_noop_when_set()
        {
            var type = new MockType();
            var innerConfig = new EntityTypeConfiguration(type);
            innerConfig.ToTable("Table1", "Schema1");
            var config = new LightweightEntityConfiguration(type, () => innerConfig);

            config.ToTable("Table2", "Schema2");

            Assert.Equal("Table1", innerConfig.TableName);
            Assert.Equal("Schema1", innerConfig.SchemaName);
        }
开发者ID:jwanagel,项目名称:jjwtest,代码行数:12,代码来源:LightweightEntityConfigurationTests.cs

示例3: ToTable_is_noop_when_set

        public void ToTable_is_noop_when_set()
        {
            var type = new MockType();
            var innerConfig = new EntityTypeConfiguration(type);
            innerConfig.ToTable("Table1");
            var config = new ConventionTypeConfiguration(type, () => innerConfig, new ModelConfiguration());

            config.ToTable("Table2");

            Assert.Equal("Table1", innerConfig.TableName);
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:11,代码来源:ConventionTypeConfigurationTests.cs

示例4: Apply_should_match_key_that_is_an_fk_used_in_table_splitting

        public void Apply_should_match_key_that_is_an_fk_used_in_table_splitting()
        {
            var model = new EdmModel(DataSpace.CSpace);
            var entityType = new EntityType("E", "N", DataSpace.CSpace);
            var property = EdmProperty.CreatePrimitive("P", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int64));

            entityType.AddKeyMember(property);

            var targetConfig = new EntityTypeConfiguration(typeof(object));
            targetConfig.ToTable("SharedTable");
            entityType.GetMetadataProperties().SetConfiguration(targetConfig);

            var sourceEntityType = new EntityType("E", "N", DataSpace.CSpace);
            var sourceConfig = new EntityTypeConfiguration(typeof(object));
            sourceConfig.ToTable("SharedTable");
            sourceEntityType.GetMetadataProperties().SetConfiguration(sourceConfig);

            var associationType
                = model.AddAssociationType(
                    "A", sourceEntityType, RelationshipMultiplicity.One,
                    entityType, RelationshipMultiplicity.One);

            associationType.Constraint
                = new ReferentialConstraint(
                    associationType.SourceEnd,
                    associationType.TargetEnd,
                    new[] { property },
                    new[] { property });

            (new StoreGeneratedIdentityKeyConvention())
                .Apply(entityType, new DbModel(model, null));

            Assert.Equal(
                StoreGeneratedPattern.Identity,
                entityType.KeyProperties.Single().GetStoreGeneratedPattern());
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:36,代码来源:StoreGeneratedIdentityKeyConventionTests.cs

示例5: Apply_should_match_key_that_is_an_fk_used_in_table_splitting

        public void Apply_should_match_key_that_is_an_fk_used_in_table_splitting()
        {
            var model = new EdmModel().Initialize();
            var entityType = new EdmEntityType();
            var property = new EdmProperty().AsPrimitive();

            property.PropertyType.EdmType = EdmPrimitiveType.Int64;
            entityType.DeclaredKeyProperties.Add(property);

            var targetConfig = new EntityTypeConfiguration(typeof(object));
            targetConfig.ToTable("SharedTable");
            entityType.SetConfiguration(targetConfig);

            var sourceEntityType = new EdmEntityType();
            var sourceConfig = new EntityTypeConfiguration(typeof(object));
            sourceConfig.ToTable("SharedTable");
            sourceEntityType.SetConfiguration(sourceConfig);

            var associationType
                = model.AddAssociationType(
                    "A", sourceEntityType, EdmAssociationEndKind.Required,
                    entityType, EdmAssociationEndKind.Required);
            associationType.Constraint = new EdmAssociationConstraint();
            associationType.Constraint.DependentProperties.Add(property);

            ((IEdmConvention<EdmEntityType>)new StoreGeneratedIdentityKeyConvention())
                .Apply(entityType, model);

            Assert.Equal(
                DbStoreGeneratedPattern.Identity,
                entityType.DeclaredKeyProperties.Single().GetStoreGeneratedPattern());
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:32,代码来源:StoreGeneratedIdentityKeyConventionTests.cs

示例6: ToTable_overwrites_existing_name

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

            entityTypeConfiguration.ToTable("Foo");
            entityTypeConfiguration.ToTable("Bar");

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

示例7: 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:Cireson,项目名称:EntityFramework6,代码行数:9,代码来源:EntityTypeConfigurationTests.cs

示例8: SchemaName_returns_current_SchemaName

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

            Assert.Equal(null, entityTypeConfiguration.SchemaName);

            entityTypeConfiguration.ToTable("Foo", "Bar");
            Assert.Equal("Bar", entityTypeConfiguration.SchemaName);
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:9,代码来源:EntityTypeConfigurationTests.cs

示例9: 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:Cireson,项目名称:EntityFramework6,代码行数:7,代码来源:EntityTypeConfigurationTests.cs


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