コード例 #1
0
 public override List<SchemaIndexColumn> GetIndexColumns(string owner, string tableName, string indexName)
 {
     using (DbConnectionInfo cn = Db.CreateConnection())
     {
         DataTable dt = cn.GetSchema("IndexColumns", new string[] { cn.Database, owner, tableName, indexName });
         DataRowCollection drc = dt.Rows;
         List<SchemaIndexColumn> list = new List<SchemaIndexColumn>(drc.Count);
         for (int i = 0; i < drc.Count; i++)
         {
             SchemaIndexColumn item = new SchemaIndexColumn();
             item.IndexOwner = drc[i]["INDEX_OWNER"].IfNull(String.Empty);
             item.IndexName = drc[i]["INDEX_NAME"].IfNull(String.Empty);
             item.TableOwner = drc[i]["TABLE_OWNER"].IfNull(String.Empty);
             item.TableName = drc[i]["TABLE_NAME"].IfNull(String.Empty);
             item.OrdinalPosition = drc[i]["COLUMN_POSITION"].IfNull(0);
             item.ColumnName = drc[i]["COLUMN_NAME"].IfNull(String.Empty);
             //drc[i]["DESCEND"]
             list.Add(item);
         }
         return list;
     }
 }
コード例 #2
0
 public override List<SchemaIndexColumn> GetIndexColumns(string owner, string tableName, string indexName)
 {
     using (DbConnectionInfo cn = Db.CreateConnection())
     {
         DataTable dt = cn.GetSchema("IndexColumns", new string[] { cn.Database, owner, tableName, indexName });
         DataRowCollection drc = dt.Rows;
         List<SchemaIndexColumn> list = new List<SchemaIndexColumn>(drc.Count);
         for (int i = 0; i < drc.Count; i++)
         {
             SchemaIndexColumn item = new SchemaIndexColumn();
             item.IndexOwner = drc[i]["constraint_schema"].IfNull(String.Empty);
             item.IndexName = drc[i]["constraint_name"].IfNull(String.Empty);
             item.TableOwner = drc[i]["table_schema"].IfNull(String.Empty);
             item.TableName = drc[i]["table_name"].IfNull(String.Empty);
             item.OrdinalPosition = drc[i]["ordinal_position"].IfNull(0);
             item.ColumnName = drc[i]["column_name"].IfNull(String.Empty);
             //drc[i]["keytype"] //56 unique key, 167 index, 108 primary key...
             list.Add(item);
         }
         return list;
     }
 }