public void GetColumns() { IList<SqlColumnInfo> customer_columns; IList<SqlColumnInfo> order_columns; using (var reader = new SqlSchemaReader(_cstr_db)) { customer_columns = reader.GetColumns("dbo.customer"); order_columns = reader.GetColumns("[dbo].[ORDER]"); } Assert.IsTrue(customer_columns.Any()); Assert.IsTrue(order_columns.Any()); var id_column = customer_columns.SingleOrDefault(c => c.Name == "Id"); Assert.IsNotNull(id_column); Assert.IsTrue(id_column.Identity); Assert.IsFalse(id_column.Nullable); Assert.IsTrue(id_column.ColumnId == 1); var name_column = customer_columns.SingleOrDefault(c => c.Name == "FirstName"); Assert.IsNotNull(name_column); Assert.IsFalse(name_column.Identity); Assert.IsTrue(name_column.Nullable); Assert.IsTrue(name_column.ColumnId == 3); }
public void GetColumns() { IList <SqlColumnInfo> customer_columns; IList <SqlColumnInfo> order_columns; using (var reader = new SqlSchemaReader(_cstr_db)) { customer_columns = reader.GetColumns("dbo.customer"); order_columns = reader.GetColumns("[dbo].[ORDER]"); } Assert.IsTrue(customer_columns.Any()); Assert.IsTrue(order_columns.Any()); var id_column = customer_columns.SingleOrDefault(c => c.Name == "Id"); Assert.IsNotNull(id_column); Assert.IsTrue(id_column.Identity); Assert.IsFalse(id_column.Nullable); Assert.IsTrue(id_column.ColumnId == 1); var name_column = customer_columns.SingleOrDefault(c => c.Name == "FirstName"); Assert.IsNotNull(name_column); Assert.IsFalse(name_column.Identity); Assert.IsTrue(name_column.Nullable); Assert.IsTrue(name_column.ColumnId == 3); }
void LoadDB_DoWork(object sender, DoWorkEventArgs e) { string conn; BaseSchemaReader sr; System.ComponentModel.BackgroundWorker worker; worker = (System.ComponentModel.BackgroundWorker)sender; worker.WorkerReportsProgress = true; // the language generator here is used to project the primitive variable types // this approach has been changed to have the types mapped to a logical model // the xslt defines the target type map for the specific language LanguageGenerator langGen = LanguageGenerator.CodeGenerator(ProjectDefinition.Settings.CodeLanguage); if (ProjectDefinition.Settings.ConnectionString == null) { // provide a popup to get the connection string conn = dataSource.ConnectionString; ProjectDefinition.Settings.ConnectionString = conn; } else { conn = ProjectDefinition.Settings.ConnectionString; } sr = new SqlSchemaReader(langGen, conn); sr.Filter = _filter; sr.WorkerThread = worker; ProjectDefinition.Model = new Model(); ProjectDefinition.Model.OnEntityAdding += new Model.EntityAdding(Model_OnEntityAdding); ProjectDefinition.Model.BuildModel(sr); }
public void GetAllTablesWithSchema() { IList<string> tables; using (var reader = new SqlSchemaReader(_cstr_db)) { tables = reader.GetTables(null); } Assert.IsTrue(tables.Contains("[dbo].[Customer]"), "dbo.Customer not found"); Assert.IsTrue(tables.Contains("[dbo].[Order]"), "dbo.Order not found"); Assert.IsTrue(tables.Contains("[inventory].[Item]"), "inventory.Item not found"); }
public void GetdboTablesWithSchema() { IList <string> tables; using (var reader = new SqlSchemaReader(_cstr_db)) { tables = reader.GetTables("dbo"); } Assert.IsTrue(tables.Contains("[dbo].[Customer]"), "dbo.Customer not found"); Assert.IsTrue(tables.Contains("[dbo].[Order]"), "dbo.Order not found"); Assert.IsFalse(tables.Contains("[inventory].[Item]"), "inventory.Item not found"); }