예제 #1
0
 public GenerateCdmFromDatabaseCommand(
     ILogger <GenerateCdmFromDatabaseCommand> logger, IRelationalModelReader relationalModelReader,
     SqlRelationalModelAnnotationCombiner annotationCombiner, CdmGenerator cdmGenerator)
 {
     this.logger = logger;
     this.relationalModelReader = relationalModelReader;
     this.annotationCombiner    = annotationCombiner;
     this.cdmGenerator          = cdmGenerator;
 }
예제 #2
0
 public GenerateCdmFromFileCommand(
     ILogger <GenerateCdmFromFileCommand> logger, SqlTextCommandAdapter sqlFileAdapter, IRelationalModelReader relationalModelReader,
     SqlRelationalModelAnnotationCombiner annotationCombiner, CdmGenerator cdmGenerator)
 {
     this.logger                = logger;
     this.sqlCommandAdapter     = sqlFileAdapter;
     this.relationalModelReader = relationalModelReader;
     this.annotationCombiner    = annotationCombiner;
     this.cdmGenerator          = cdmGenerator;
 }
예제 #3
0
        public void ReadsNonNullRelationalModel()
        {
            var sql = @"CREATE TABLE Customer (
				            CUSTOMER_ID INT
                        );";

            ExecuteSqlCommand(sql);
            IRelationalModelReader reader = CreateRelationalModelReader();

            RelationalModel model = reader.ReadRelationalModel();

            Assert.NotNull(model);
        }
예제 #4
0
        public void ReadsColumnIsPrimaryKey(string statement, bool expected)
        {
            var sql = $@"CREATE TABLE Customer (
							CUSTOMER_ID INT {statement}
                        );";

            ExecuteSqlCommand(sql);
            IRelationalModelReader reader = CreateRelationalModelReader();

            Column column = reader.ReadRelationalModel().GetColumn();

            Assert.Equal(expected, column.IsPrimaryKey);
        }
예제 #5
0
        public void ReadsColumnType(string type, SqlDbType expected)
        {
            var sql = $@"CREATE TABLE Customer (
							CUSTOMER_ID {type}
                        );";

            ExecuteSqlCommand(sql);
            IRelationalModelReader reader = CreateRelationalModelReader();

            Column column = reader.ReadRelationalModel().GetColumn();

            Assert.Equal(expected, column.Type);
        }
예제 #6
0
        public void ReadsColumnName(string name, string expected)
        {
            var sql = $@"CREATE TABLE Customer (
							{name} INT
                        );";

            ExecuteSqlCommand(sql);
            IRelationalModelReader reader = CreateRelationalModelReader();

            Column column = reader.ReadRelationalModel().GetColumn();

            Assert.Equal(expected, column.Name);
        }
예제 #7
0
        public void ReadsSingleTable()
        {
            var sql = @"CREATE TABLE Customer (
							CUSTOMER_ID INT
                        );";

            ExecuteSqlCommand(sql);
            IRelationalModelReader reader = CreateRelationalModelReader();

            RelationalModel     model  = reader.ReadRelationalModel();
            IEnumerable <Table> tables = model.Tables;

            Assert.Single(tables);
        }
예제 #8
0
        public void ReadsSingleColumn()
        {
            var sql = @"CREATE TABLE Customer (
							CUSTOMER_ID INT
                        );";

            ExecuteSqlCommand(sql);
            IRelationalModelReader reader = CreateRelationalModelReader();

            RelationalModel      model   = reader.ReadRelationalModel();
            IEnumerable <Column> columns = model.GetTable().Columns;

            Assert.Single(columns);
        }
예제 #9
0
        public void ReadsTableName(string name, string expected)
        {
            var sql = $@"CREATE TABLE {name} (
							CUSTOMER_ID INT
                        );";

            ExecuteSqlCommand(sql);
            IRelationalModelReader reader = CreateRelationalModelReader();

            RelationalModel model = reader.ReadRelationalModel();
            Table           table = model.GetTable();

            Assert.Equal(expected, table.Name);
        }
예제 #10
0
        public void ReadsColumnLength()
        {
            var sql = @"CREATE TABLE Customer (
							CUSTOMER_ID VARCHAR(10)
                        );";

            ExecuteSqlCommand(sql);
            IRelationalModelReader reader = CreateRelationalModelReader();

            RelationalModel model  = reader.ReadRelationalModel();
            Column          column = model.GetColumn();

            Assert.NotNull(column.Length);
            Assert.Equal(10, column.Length.MaxSize);
        }
예제 #11
0
        public void ReadsColumnTable()
        {
            var sql = @"CREATE TABLE Customer (
							CUSTOMER_ID INT
                        );";

            ExecuteSqlCommand(sql);
            IRelationalModelReader reader = CreateRelationalModelReader();

            RelationalModel model  = reader.ReadRelationalModel();
            Table           table  = model.GetTable();
            Column          column = model.GetColumn();

            Assert.NotNull(column.Table);
            Assert.Same(table, column.Table);
        }
예제 #12
0
        public void ReadsColumnIsForeignKey()
        {
            var sql = @"CREATE TABLE Customer (
                            CUSTOMER_ID INT PRIMARY KEY
                        );
                        CREATE TABLE CustomerAddresses (
                            CUSTOMER_ADDRESS_ID INT PRIMARY KEY,
                            CUSTOMER_ID INT,
                            FOREIGN KEY(CUSTOMER_ID) REFERENCES Customer(CUSTOMER_ID)
                        );";

            ExecuteSqlCommand(sql);
            IRelationalModelReader reader = CreateRelationalModelReader();

            Column column = reader.ReadRelationalModel().GetColumn("CustomerAddresses", "CUSTOMER_ID");

            Assert.True(column.IsForeignKey);
        }
예제 #13
0
        public void ReadsColumnForeignKeyTable()
        {
            var sql = @"CREATE TABLE Customer (
                            CUSTOMER_ID INT PRIMARY KEY
                        );
                        CREATE TABLE CustomerAddresses (
                            CUSTOMER_ADDRESS_ID INT PRIMARY KEY,
                            CUSTOMER_ID INT,
                            FOREIGN KEY(CUSTOMER_ID) REFERENCES Customer(CUSTOMER_ID)
                        );";

            ExecuteSqlCommand(sql);
            IRelationalModelReader reader = CreateRelationalModelReader();

            RelationalModel model      = reader.ReadRelationalModel();
            Column          fromColumn = model.GetColumn("CustomerAddresses", "CUSTOMER_ID");
            Table           toTable    = model.GetTable("Customer");

            Assert.Same(toTable, fromColumn.ForeignKey.Table);
        }