private TableAnalyser GetLoadedConstraints(TableStructure table) { { var res = (TableAnalyser)AnalyserCache.GetTableAnalyser("constraints"); if (res != null) { return(res); } res = (TableAnalyser)AnalyserCache.GetTableAnalyser("constraints:" + table.FullName.ToString()); if (res != null) { return(res); } } InformationSchema ins = InformationSchema.LoadSchemaOnce(GetDbConn, m_conn.GetConnKey()); if (m_members.TableFilter != null && m_members.TableFilter.Count == 1) { // load constraint for one table TableAnalyser ta = new TableAnalyser(); ConstraintsLoader loader = new ConstraintsLoader(GetDbConn(), ins, ta, table.FullName, m_members.TableMembers & GetConstraintLoadMode(), GetDbNameCondition()); loader.Run(); AnalyserCache.PutTableAnalyser("constraints:" + table.FullName.ToString(), ta); return(ta); } else { // load constraints for all tables TableAnalyser ta = new TableAnalyser(); ConstraintsLoader loader = new ConstraintsLoader(GetDbConn(), ins, ta, null, m_members.TableMembers & GetConstraintLoadMode(), GetDbNameCondition()); loader.Run(); AnalyserCache.PutTableAnalyser("constraints", ta); return(ta); } }
public override string Generate(ConstraintsLoader loader, string table, ref bool cancel) { StringBuilder sb = new StringBuilder(); bool wascond = false; sb.Append("("); foreach (Condition cond in Conditions) { string conds = cond.Generate(loader, table, ref cancel); if (cancel) { return(null); } if (conds == null) { continue; } if (wascond) { sb.Append(" " + SqlName + " "); } sb.Append(conds); wascond = true; } sb.Append(")"); if (!wascond) { return(null); } return(sb.ToString()); }
public override string Generate(ConstraintsLoader loader, string table, ref bool cancel) { if (!loader.m_infoSchema.HasColumn(table, m_name)) { if (m_mandatory) { cancel = true; } return(null); } return(String.Format("{0}='{1}'", m_name, m_value)); }
public override string Generate(ConstraintsLoader loader, string table, ref bool cancel) { if (m_schema == null) { return(null); } if (loader.m_infoSchema.HasColumn(table, "table_schema")) { return(String.Format("table_schema='{0}'", m_schema)); } if (loader.m_infoSchema.HasColumn(table, "constraint_schema")) { return(String.Format("constraint_schema='{0}'", m_schema)); } return(null); }
public abstract string Generate(ConstraintsLoader loader, string table, ref bool cancel);