public TableName[] GetDependencyTableNames(DatabaseName databaseName) { var dict = rows.GroupBy( row => row.FkTable, (Key, rows) => new { FkTable = Key, PkTables = rows.Select(row => row.PkTable).ToArray() }) .ToDictionary(row => row.FkTable, row => row.PkTables); TableName[] names = databaseName.GetTableNames(); List <TableName> history = new List <TableName>(); foreach (var tname in names) { if (history.IndexOf(tname) < 0) { Iterate(tname, dict, history); } } return(history.ToArray()); }
private static DataTable LoadDatabaseSchema(DatabaseName dname) { List <SchemaRow> rows = new List <SchemaRow>(); foreach (TableName tname in dname.GetTableNames()) { LoadColumns(rows, tname); LoadForeignKeys(rows, tname); } DataTable schemaTable = SchemaRowExtension.CreateTable(); rows.ToDataTable(schemaTable); schemaTable.AcceptChanges(); return(schemaTable); }