public static void ImportChildRelations(ITable srcTab, TableDefinitionDataTable destTabs) { foreach (IForeignKey srcFK in srcTab.ForeignKeys) { if (srcTab == srcFK.PrimaryTable) // use only childrelations { TableDefinitionRow childTab = destTabs.FindByTableName(srcFK.ForeignTable.Name); TableDefinitionRow parentTab = destTabs.FindByTableName(srcFK.PrimaryTable.Name); if ((childTab == null) || (parentTab == null)) { return; // both tables are not included } String relationName = parentTab.Table.DataSet.RelationDefinition.CreateUniqueRelationName(srcFK.Name, childTab.TableName, parentTab.TableName); RelationDefinitionRow curRelation = parentTab.InsertNewRelation(relationName, childTab.TableName); IColumns parentColums = srcFK.PrimaryColumns; IColumns childColums = srcFK.ForeignColumns; FieldRelationDefinitionRow curFieldRelation = null; for (int colNo = 0; colNo < parentColums.Count; colNo++) { curFieldRelation = curRelation.InsertNewFieldRelation(parentColums[colNo].Name, childColums[colNo].Name); } } // if (srcTab == srcFK.PrimaryTable) // use only childrelations } // foreach (IForeignKey srcFK in srcTab.ForeignKeys) }
public static void ImportRelations(IDatabase srcDb, SchemaXsd3bEx destSet) { TableDefinitionDataTable destTabs = destSet.TableDefinition; foreach (ITable srcTab in srcDb.Tables) { ImportChildRelations(srcTab, destTabs); } }
public static void ImportTable(ITable srcTab, TableDefinitionDataTable destTabs) { TableDefinitionRow destTab = destTabs.FindByTableName(srcTab.Name); if (destTab == null) { destTab = destTabs.NewTableDefinitionRow(); destTab.TableName = srcTab.Name; destTabs.AddTableDefinitionRow(destTab); } ImportTable(srcTab, destTab); }
public static void ImportProc(IProcedure srcProc, TableDefinitionDataTable destTabs) { System.Diagnostics.Debug.WriteLine("Import Proc " + srcProc.Name); TableDefinitionRow destTab = destTabs.FindByTableName(srcProc.Name); if (destTab == null) { destTab = destTabs.NewTableDefinitionRow(); destTab.TableName = srcProc.Name; destTabs.AddTableDefinitionRow(destTab); } ImportProc(srcProc, destTab); }
public static void ImportView(IView srcView, TableDefinitionDataTable destTabs) { System.Diagnostics.Debug.WriteLine("Import View " + srcView.Name); TableDefinitionRow destTab = destTabs.FindByTableName(srcView.Name); if (destTab == null) { destTab = destTabs.NewTableDefinitionRow(); destTab.TableName = srcView.Name; destTabs.AddTableDefinitionRow(destTab); } ImportView(srcView, destTab); }
public static void ImportChildRelations(ITable srcTab, TableDefinitionDataTable destTabs) { foreach (IForeignKey srcFK in srcTab.ForeignKeys) { if (srcTab == srcFK.PrimaryTable) // use only childrelations { TableDefinitionRow childTab = destTabs.FindByTableName(srcFK.ForeignTable.Name); TableDefinitionRow parentTab = destTabs.FindByTableName(srcFK.PrimaryTable.Name); if ((childTab == null) || (parentTab == null)) return; // both tables are not included String relationName = parentTab.Table.DataSet.RelationDefinition.CreateUniqueRelationName(srcFK.Name, childTab.TableName, parentTab.TableName); RelationDefinitionRow curRelation = parentTab.InsertNewRelation(relationName, childTab.TableName); IColumns parentColums = srcFK.PrimaryColumns; IColumns childColums = srcFK.ForeignColumns; FieldRelationDefinitionRow curFieldRelation = null; for (int colNo = 0; colNo < parentColums.Count; colNo++) { curFieldRelation = curRelation.InsertNewFieldRelation(parentColums[colNo].Name, childColums[colNo].Name); } } // if (srcTab == srcFK.PrimaryTable) // use only childrelations } // foreach (IForeignKey srcFK in srcTab.ForeignKeys) }