private static TableInfo LoadTableInfo(IDictionary<TableName, TableInfo> tables, TableName tablename) { TableInfo table; if (!tables.TryGetValue(tablename, out table)) { table = new TableInfo(tablename); tables.Add(table.Name, table); } return table; }
private static void LoadColumnInfo(SqlDataReader dr, IDictionary<TableName, TableInfo> tables) { while (dr.Read()) { TableName tablename = new TableName((string)dr["SchemaName"], (string)dr["TableName"]); TableInfo table = LoadTableInfo(tables, tablename); ColumnInfo column = new ColumnInfo(dr["ColumnName"], dr["Type"], dr["Size"], dr["Precision"], dr["Scale"], dr["IsNullable"], dr["IsIdentity"], dr["IdentitySeed"], dr["IdentityIncrement"], dr["Calculation"], dr["Position"], dr["Collation"]); table.Columns.Add(column); table.HasIdentity |= column.IsIdentity; } }
private static void LoadPrimaryKeyInfo(SqlDataReader dr, IDictionary<TableName, TableInfo> tables) { while (dr.Read()) { TableName tablename = new TableName((string)dr["SchemaName"], (string)dr["TableName"]); TableInfo table = LoadTableInfo(tables, tablename); KeyInfo primarykey = table.PrimaryKey; if (primarykey == null) { primarykey = new KeyInfo(dr["ConstraintName"], dr["IsClustered"], dr["IsPrimaryKey"], dr["IsUnique"], dr["IsConstraint"]); table.PrimaryKey = primarykey; } ColumnInfo column = table.Columns[table.ColumnIndex((string)dr["ColumnName"])]; column.IsDescending = dr["IsDescending"].Equals(1); primarykey.Columns.Add(column); } }
public TableInfo(TableName name) { Name = name; }