Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
 public ConstraintsLoader(DbConnection conn, InformationSchema infoSchema, TableAnalyser analyser, NameWithSchema table, TableStructureMembers members, Condition dbnamecond)
 {
     m_conn       = conn;
     m_infoSchema = infoSchema;
     m_table      = table;
     m_analyser   = analyser;
     m_members    = members;
     m_dbnamecond = dbnamecond;
 }
Ejemplo n.º 3
0
        public static InformationSchema LoadSchemaOnce(Func <DbConnection> conn, string groupId)
        {
            lock (m_schemaByGroupId)
            {
                if (m_schemaByGroupId.ContainsKey(groupId))
                {
                    return(m_schemaByGroupId[groupId]);
                }
            }
            InformationSchema res = new InformationSchema();

            res.Load(conn());
            lock (m_schemaByGroupId)
            {
                m_schemaByGroupId[groupId] = res;
            }
            return(res);
        }