public List <SBD.DbObject> GetDbObjects(SBD.DbType dbType, SBD.DbObjectType objectType, string connectionString, bool includeProperties = true) { List <SBD.DbObject> dbObjects = new List <SBD.DbObject>(); using (var dbConnection = GetDbConnection(dbType, connectionString)) { var tables = dbConnection.GetSchema(objectType == SBD.DbObjectType.Table ? "Tables" : "Views"); var catalogCol = dbType == SBD.DbType.SqlServer ? tables.Columns["TABLE_CATALOG"] : null; var ownerCol = dbType == SBD.DbType.SqlServer ? tables.Columns["TABLE_SCHEMA"] : tables.Columns["OWNER"]; var tableNameCol = objectType == SBD.DbObjectType.View && dbType != SBD.DbType.SqlServer ? tables.Columns["VIEW_NAME"] : tables.Columns["TABLE_NAME"]; foreach (DataRow tableRow in tables.Rows) { var objectCatalog = dbType == SBD.DbType.SqlServer ? (string)tableRow[catalogCol] : string.Empty; var objectOwner = (string)tableRow[ownerCol]; var objectName = (string)tableRow[tableNameCol]; var dbObject = new SBD.DbObject() { SchemaName = objectOwner, Name = objectName, ObjectType = objectType, //Properties = includeProperties ? GetDbObjectProperties(dbType, objectType, dbConnection, objectCatalog, objectOwner, objectName) // : new List<SBD.DbObjectProperty>() }; dbObjects.Add(dbObject); } } return(dbObjects); }
public List <SBD.DbObject> GetDbObjects(SBD.DatabaseType dbType, DbConnection dbConnection, SBD.DbObjectType objectType) { List <SBD.DbObject> dbObjects = new List <SBD.DbObject>(); var tables = dbConnection.GetSchema(objectType == SBD.DbObjectType.Table ? "Tables" : "Views"); var catalogCol = dbType == SBD.DatabaseType.SqlServer ? tables.Columns["TABLE_CATALOG"] : null; var ownerCol = dbType == SBD.DatabaseType.SqlServer ? tables.Columns["TABLE_SCHEMA"] : tables.Columns["OWNER"]; var tableNameCol = objectType == SBD.DbObjectType.View && dbType != SBD.DatabaseType.SqlServer ? tables.Columns["VIEW_NAME"] : tables.Columns["TABLE_NAME"]; foreach (DataRow tableRow in tables.Rows) { var objectCatalog = dbType == SBD.DatabaseType.SqlServer ? (string)tableRow[catalogCol] : string.Empty; var objectOwner = (string)tableRow[ownerCol]; var objectName = (string)tableRow[tableNameCol]; var dbObject = new SBD.DbObject() { SchemaName = objectOwner, Name = objectName, ObjectType = objectType }; dbObjects.Add(dbObject); } return(dbObjects); }