/// <summary> /// Loads and returns the Schema for the specified table /// </summary> /// <param name="catalog"></param> /// <param name="schema"></param> /// <param name="name">The required name of the table to get the schema for. Cannot be null or empty</param> /// <returns></returns> public DBSchemaTable GetTableSchema(string catalog, string schema, string name) { if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException("name"); } DBSchemaItemRef itemref = new DBSchemaItemRef(); itemref.Catalog = catalog; itemref.Schema = schema; itemref.Name = name; itemref.Type = DBSchemaTypes.Table; return(this.GetTableSchema(itemref)); }
public DBSchemaView GetViewSchema(string catalog, string owner, string name) { if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException("name"); } DBSchemaItemRef itemref = new DBSchemaItemRef(); itemref.Catalog = catalog; itemref.Schema = owner; itemref.Name = name; itemref.Type = DBSchemaTypes.View; return(this.GetViewSchema(itemref)); }
public DBSchemaTable GetTableSchema(DBSchemaItemRef tableRef) { if (null == tableRef) { throw new ArgumentNullException("tableRef"); } if (string.IsNullOrEmpty(tableRef.Name)) { throw new ArgumentNullException("tableRef.Name"); } if (tableRef.Type != DBSchemaTypes.Table) { throw new ArgumentOutOfRangeException("tableRef.Type"); } using (DbConnection con = this.Database.CreateConnection()) { con.Open(); return(this.LoadATable(con, tableRef)); } }
public DBSchemaView GetViewSchema(DBSchemaItemRef viewRef) { if (null == viewRef) { throw new ArgumentNullException("viewRef"); } if (string.IsNullOrEmpty(viewRef.Name)) { throw new ArgumentNullException("viewRef.Name"); } if (viewRef.Type != DBSchemaTypes.View) { throw new ArgumentOutOfRangeException("viewRef.Type"); } using (DbConnection con = this.Database.CreateConnection()) { con.Open(); DBSchemaView view = this.LoadAView(con, viewRef); return(view); } }
// // protected implementation // /// <summary> /// Loads a complete schema for the specified Table schema reference including all columns, and indexes. /// </summary> #region protected virtual DBSchemaTable LoadATable(DbConnection con, DBSchemaItemRef forRef) /// <param name="con"></param> /// <param name="forRef"></param> /// <returns></returns> protected virtual DBSchemaTable LoadATable(DbConnection con, DBSchemaItemRef forRef) { DBSchemaTable sTbl = null; string catalog = string.IsNullOrEmpty(forRef.Catalog) ? null : forRef.Catalog; string schema = string.IsNullOrEmpty(forRef.Schema) ? null : forRef.Schema; DataTable tbl = con.GetSchema(SchemaTablesName, new string[] { catalog, schema, forRef.Name, null }); DataTable columns = con.GetSchema(SchemaColumnsName, new string[] { catalog, schema, forRef.Name, null }); if (tbl.Rows.Count > 0) { DataRow tblRow = tbl.Rows[0]; TableMappingClass tblmapping = this.GetTableMapping(); TableColumnMappingClass tblcolmapping = this.GetTableColumnMapping(); sTbl = CreateSchemaTable(tblmapping, tblRow); FillTableColumns(sTbl, tblcolmapping, columns); } return(sTbl); }
protected abstract DBSchemaView LoadAView(DbConnection con, DBSchemaItemRef forRef);