コード例 #1
0
        /// <summary>
        ///     Configures the table name that this entity type is mapped to.
        /// </summary>
        /// <param name="tableName"> The name of the table. </param>
        /// <remarks>
        ///     Calling this will have no effect once it has been configured.
        /// </remarks>
        public ConventionTypeConfiguration <T> ToTable(string tableName)
        {
            Check.NotEmpty(tableName, "tableName");

            _configuration.ToTable(tableName);

            return(this);
        }
コード例 #2
0
        public void ToTable_with_schema_configures()
        {
            var type        = typeof(LocalEntityType);
            var innerConfig = new EntityTypeConfiguration(type);
            var config      = new ConventionTypeConfiguration <LocalEntityType>(type, () => innerConfig, new ModelConfiguration());

            config.ToTable("foo", "bar");

            Assert.Equal("foo", innerConfig.TableName);
        }
コード例 #3
0
        public void ToTable_configures_when_unset()
        {
            var type        = new MockType();
            var innerConfig = new EntityTypeConfiguration(type);
            var config      = new ConventionTypeConfiguration(type, () => innerConfig, new ModelConfiguration());

            config.ToTable("Table1");

            Assert.Equal("Table1", innerConfig.TableName);
        }
コード例 #4
0
        public void ToTable_with_schema_evaluates_preconditions()
        {
            var type        = new MockType();
            var innerConfig = new EntityTypeConfiguration(type);
            var config      = new ConventionTypeConfiguration(type, () => innerConfig, new ModelConfiguration());

            var ex = Assert.Throws <ArgumentException>(
                () => config.ToTable(null, null));

            Assert.Equal(Strings.ArgumentIsNullOrWhitespace("tableName"), ex.Message);
        }
コード例 #5
0
        public void ToTable_handles_dot()
        {
            var type        = new MockType();
            var innerConfig = new EntityTypeConfiguration(type);
            var config      = new ConventionTypeConfiguration(type, () => innerConfig, new ModelConfiguration());

            config.ToTable("Schema1.Table1");

            Assert.Equal("Schema1", innerConfig.SchemaName);
            Assert.Equal("Table1", innerConfig.TableName);
        }
コード例 #6
0
        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 ConventionTypeConfiguration(type, () => innerConfig, new ModelConfiguration());

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

            Assert.Equal("Table1", innerConfig.TableName);
            Assert.Equal("Schema1", innerConfig.SchemaName);
        }
コード例 #7
0
        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 ConventionTypeConfiguration(type, () => innerConfig, new ModelConfiguration());

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

            Assert.Equal("Table1", innerConfig.TableName);
            Assert.Equal("Schema1", innerConfig.SchemaName);
        }
コード例 #8
0
        public void ToTable_with_schema_evaluates_preconditions()
        {
            var type = new MockType();
            var innerConfig = new EntityTypeConfiguration(type);
            var config = new ConventionTypeConfiguration(type, () => innerConfig, new ModelConfiguration());

            var ex = Assert.Throws<ArgumentException>(
                () => config.ToTable(null, null));

            Assert.Equal(Strings.ArgumentIsNullOrWhitespace("tableName"), ex.Message);
        }
コード例 #9
0
        public void ToTable_handles_dot()
        {
            var type = new MockType();
            var innerConfig = new EntityTypeConfiguration(type);
            var config = new ConventionTypeConfiguration(type, () => innerConfig, new ModelConfiguration());

            config.ToTable("Schema1.Table1");

            Assert.Equal("Schema1", innerConfig.SchemaName);
            Assert.Equal("Table1", innerConfig.TableName);
        }
コード例 #10
0
        public void ToTable_configures_when_unset()
        {
            var type = new MockType();
            var innerConfig = new EntityTypeConfiguration(type);
            var config = new ConventionTypeConfiguration(type, () => innerConfig, new ModelConfiguration());

            config.ToTable("Table1");

            Assert.Equal("Table1", innerConfig.TableName);
        }
        public void ToTable_with_schema_configures()
        {
            var type = typeof(LocalEntityType);
            var innerConfig = new EntityTypeConfiguration(type);
            var config = new ConventionTypeConfiguration<LocalEntityType>(type, () => innerConfig, new ModelConfiguration());

            config.ToTable("foo", "bar");

            Assert.Equal("foo", innerConfig.TableName);
        }