public override List<SchemaColumn> GetColumns(string owner, string tableName) { using (DbConnectionInfo cn = Db.CreateConnection()) { //owner, table name, column_name DataTable dt = cn.GetSchema("Columns", new string[] { owner, tableName, null }); DataRowCollection drc = dt.Rows; List<SchemaColumn> list = new List<SchemaColumn>(drc.Count); for (int i = 0; i < drc.Count; i++) { SchemaColumn item = new SchemaColumn(); item.Owner = drc[i]["OWNER"].IfNull(String.Empty); item.TableName = drc[i]["TABLE_NAME"].IfNull(String.Empty); item.ColumnName = drc[i]["COLUMN_NAME"].IfNull(String.Empty); item.OrdinalPostion = drc[i]["ID"].IfNull(0); item.DataType = drc[i]["DATA_TYPE"].IfNull(String.Empty); item.Length = drc[i]["LENGTH"].IfNull(0); item.Precision = drc[i]["PRECISION"].IfNull(0); item.Scale = drc[i]["SCALE"].IfNull(0); item.IsNullable = drc[i]["NULLABLE"].Equals("Y"); //item.DefaultValue = list.Add(item); } return list; } }
public override List<SchemaColumn> GetColumns(string owner, string tableName) { using (DbConnectionInfo cn = Db.CreateConnection()) { //catalog,schema,table name,column name DataTable dt = cn.GetSchema("Columns", new string[] { cn.Database, owner, tableName, null }); DataRowCollection drc = dt.Rows; List<SchemaColumn> list = new List<SchemaColumn>(drc.Count); for (int i = 0; i < drc.Count; i++) { SchemaColumn item = new SchemaColumn(); item.Owner = drc[i]["table_schema"].IfNull(String.Empty); item.TableName = drc[i]["table_name"].IfNull(String.Empty); item.ColumnName = drc[i]["column_name"].IfNull(String.Empty); item.OrdinalPostion = drc[i]["ordinal_position"].IfNull(0); item.DataType = drc[i]["data_type"].IfNull(String.Empty); item.Length = drc[i]["character_maximum_length"].IfNull(0); item.Precision = drc[i]["numeric_precision"].IfNull(0); item.Scale = drc[i]["numeric_scale"].IfNull(0); item.IsNullable = drc[i]["is_nullable"].Equals("YES"); item.DefaultValue = drc[i]["column_default"]; list.Add(item); } return list; } }