public GenerateCdmFromDatabaseCommand( ILogger <GenerateCdmFromDatabaseCommand> logger, IRelationalModelReader relationalModelReader, SqlRelationalModelAnnotationCombiner annotationCombiner, CdmGenerator cdmGenerator) { this.logger = logger; this.relationalModelReader = relationalModelReader; this.annotationCombiner = annotationCombiner; this.cdmGenerator = cdmGenerator; }
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; }
public void ReadsNonNullRelationalModel() { var sql = @"CREATE TABLE Customer ( CUSTOMER_ID INT );"; ExecuteSqlCommand(sql); IRelationalModelReader reader = CreateRelationalModelReader(); RelationalModel model = reader.ReadRelationalModel(); Assert.NotNull(model); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }