private void DeleteAllTables(ComponentMetastore componentMetastore) { var tables = this.GetTables(componentMetastore); using (var connection = CreateDbConnection(componentMetastore)) { foreach (var table in tables) { using (var command = new SqlCommand(string.Format("DROP TABLE {0}", table), connection)) { command.ExecuteNonQuery(); } } } }
private Collection <string> GetTables(ComponentMetastore componentMetastore) { var tables = new Collection <string>(); using (var connection = CreateDbConnection(componentMetastore)) using (var command = new SqlCommand("select name from sys.objects where type = 'U'", connection)) using (var reader = command.ExecuteReader()) { while (reader.Read()) { tables.Add(reader.GetString(0)); } } return(tables); }
private SqlConnection CreateDbConnection(ComponentMetastore metastore) { SqlConnectionStringBuilder connectionString = new SqlConnectionStringBuilder { DataSource = metastore.Server, InitialCatalog = metastore.Database, UserID = metastore.User, Password = metastore.Password, IntegratedSecurity = false, }; var connection = new SqlConnection(connectionString.ConnectionString); connection.Open(); return(connection); }
private void ValidateTable(string tableName, ComponentMetastore componentMetastore) { throw new NotImplementedException(); }
private void DeleteAllTables(ComponentMetastore componentMetastore) { var tables = this.GetTables(componentMetastore); using (var connection = CreateDbConnection(componentMetastore)) { foreach (var table in tables) using (var command = new SqlCommand(string.Format("DROP TABLE {0}", table), connection)) { command.ExecuteNonQuery(); } } }
private Collection<string> GetTables(ComponentMetastore componentMetastore) { var tables = new Collection<string>(); using (var connection = CreateDbConnection(componentMetastore)) using (var command = new SqlCommand("select name from sys.objects where type = 'U'", connection)) using (var reader = command.ExecuteReader()) { while (reader.Read()) { tables.Add(reader.GetString(0)); } } return tables; }
private SqlConnection CreateDbConnection(ComponentMetastore metastore) { SqlConnectionStringBuilder connectionString = new SqlConnectionStringBuilder { DataSource = metastore.Server, InitialCatalog = metastore.Database, UserID = metastore.User, Password = metastore.Password, IntegratedSecurity = false, }; var connection = new SqlConnection(connectionString.ConnectionString); connection.Open(); return connection; }