public void Run() { DetectAlgorithm(); List <Condition> conds = new List <Condition>(); if (m_table != null && !m_loadAllConstraints) { conds.Add(new SchemaCondition(m_table.Schema)); } if (m_table != null && !m_loadAllConstraints) { conds.Add(new EqualCondition("table_name", m_table.Name, false)); } Condition cond = new AndCondition(conds.ToArray()); if (m_members.ContainsAny(TableStructureMembers.ConstraintsNoIndexesNoRefs) || (m_members.ContainsAny(TableStructureMembers.ReferencedFrom) && m_loadAllConstraints)) { LoadConstraints(cond); if (m_loadCheckConstraints) { LoadCheckConstraints(cond); } } if (m_postgreRefs) { if (m_members.ContainsAny(TableStructureMembers.ForeignKeys | TableStructureMembers.ReferencedFrom)) { LoadKeyColumnUsage(cond); LoadReferentialConstraints(cond); } else { LoadKeyColumnUsage(cond); } } else { if (m_members.ContainsAny(TableStructureMembers.ReferencedFrom)) { List <Condition> conds2 = new List <Condition>(); if (m_table != null) { conds2.Add(new SchemaCondition(m_table.Schema)); } if (m_table != null) { conds2.Add(new EqualCondition("referenced_table_name", m_table.Name, false)); } Condition orcond = new OrCondition(cond, new AndCondition(conds2.ToArray())); LoadKeyColumnUsage(orcond); } } if (m_infoSchema.HasView("referential_constraints") && m_members.ContainsAny(TableStructureMembers.ReferencedFrom | TableStructureMembers.ForeignKeys)) { LoadForeignKeyRules(cond); } }
//public static TableStructure RemoveRe(this ITableStructure src, DatabaseCopyOptions copyOpts, ISqlDialect dialect) //{ // if (!copyOpts.CopyTable(src.FullName)) return null; // TableStructure res = new TableStructure(src); // res.MangleMappedTable(copyOpts, dialect); // return res; //} public static bool Contains(this TableStructureMembers members, TableStructureMembers test) { return(members.ContainsAny(test)); }