public SchemaConstraintLoader(SchemaExtendedReader schemaReader)
        {
            _sr = schemaReader;
            var pks = _sr.PrimaryKeys(null);
            _noPks = (pks.Rows.Count == 0);
            if (!_noPks)
            {
                _pkConverter = new SchemaConstraintConverter(pks, ConstraintType.PrimaryKey);
            }
            var fks = _sr.ForeignKeys(null);
            _noFks = (fks.Rows.Count == 0);
            if (!_noFks)
            {
                _fkConverter = new SchemaConstraintConverter(fks, ConstraintType.ForeignKey);
            }
            //foreign key columns
            var fkcols = _sr.ForeignKeyColumns(null);
            _fkColumnConverter = new ForeignKeyColumnConverter(fkcols);

            var uks = _sr.UniqueKeys(null);
            _ukConverter = new SchemaConstraintConverter(uks, ConstraintType.UniqueKey);
            var cks = _sr.CheckConstraints(null);
            _ckConverter = new SchemaConstraintConverter(cks, ConstraintType.Check);

            var dfs = _sr.DefaultConstraints(null);
            _dfConverter = new SchemaConstraintConverter(dfs, ConstraintType.Default);
        }
Exemple #2
0
        public SchemaConstraintLoader(SchemaExtendedReader schemaReader)
        {
            _sr = schemaReader;
            var pks = _sr.PrimaryKeys(null);

            _noPks = (pks.Rows.Count == 0);
            if (!_noPks)
            {
                _pkConverter = new SchemaConstraintConverter(pks, ConstraintType.PrimaryKey);
            }
            var fks = _sr.ForeignKeys(null);

            _noFks = (fks.Rows.Count == 0);
            if (!_noFks)
            {
                _fkConverter = new SchemaConstraintConverter(fks, ConstraintType.ForeignKey);
            }
            //foreign key columns
            var fkcols = _sr.ForeignKeyColumns(null);

            _fkColumnConverter = new ForeignKeyColumnConverter(fkcols);

            var uks = _sr.UniqueKeys(null);

            _ukConverter = new SchemaConstraintConverter(uks, ConstraintType.UniqueKey);
            var cks = _sr.CheckConstraints(null);

            _ckConverter = new SchemaConstraintConverter(cks, ConstraintType.Check);

            var dfs = _sr.DefaultConstraints(null);

            _dfConverter = new SchemaConstraintConverter(dfs, ConstraintType.Default);
        }
        public override IList <DatabaseConstraint> ForeignKeys(string tableName)
        {
            var dt                = _schemaReader.ForeignKeys(tableName);
            var fkcols            = _schemaReader.ForeignKeyColumns(tableName);
            var converter         = new SchemaConstraintConverter(dt, ConstraintType.ForeignKey);
            var fks               = converter.Constraints();
            var fkColumnConverter = new ForeignKeyColumnConverter(fkcols);

            fkColumnConverter.AddForeignKeyColumns(fks);
            return(fks);
        }
Exemple #4
0
        private IList <DatabaseConstraint> ForeignKeys(string tableName, string schemaName)
        {
            IList <DatabaseConstraint> fks;

            if (!_noFks)
            {
                //we have preloaded
                fks = _fkConverter.Constraints(tableName, schemaName);
                _fkColumnConverter.AddForeignKeyColumns(fks);
                return(fks);
            }
            var constraints = _sr.ForeignKeys(tableName);
            var converter   = new SchemaConstraintConverter(constraints, ConstraintType.ForeignKey);

            fks = converter.Constraints();
            var cols         = _sr.ForeignKeyColumns(tableName);
            var colConverter = new ForeignKeyColumnConverter(cols);

            colConverter.AddForeignKeyColumns(fks);
            return(fks);
        }