Esempio n. 1
0
        public override IEnumerable <ITableSourceForeignKeyInfo> GetTableSourceForeignKeys(ITableSourceInfo tableSource)
        {
            PGTableSource source = tableSource as PGTableSource;

            if (source == null)
            {
                return(null);
            }

            using (IDbConnection connection = GetConnection())
            {
                List <ITableSourceForeignKeyInfo> keys = new List <ITableSourceForeignKeyInfo>();
                // should prolly do some better inner join matching
                IDbCommand cmd = CreateCommand(connection, GetTableSourceForeignKeysQuery());
                CreateParameter(cmd, "tableName", DbType.String, source.Name);
                CreateParameter(cmd, "schemaName", DbType.String, source.Database.Identifier);

                using (IDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        keys.Add(new PGFKInfo(DatabaseServices, source, reader));
                    }
                }

                return(keys);
            }
        }
Esempio n. 2
0
        public override IEnumerable <ITableSourceColumnInfo> GetTableSourceColumns(ITableSourceInfo tableSource)
        {
            PGTableSource source = tableSource as PGTableSource;

            if (source == null)
            {
                return(null);
            }

            List <ITableSourceColumnInfo> res = new List <ITableSourceColumnInfo>();

            using (IDbConnection connection = GetConnection())
            {
                IDbCommand cmd = CreateCommand(connection, GetTableSourceColumnsQuery());

                CreateParameter(cmd, "schema", DbType.String, source.Database.Identifier);
                CreateParameter(cmd, "tableName", DbType.String, source.Name);

                using (IDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        res.Add(new PGColumnInfo(tableSource, reader));
                    }
                }


                return(res);
            }
        }
Esempio n. 3
0
        public PGFKInfo(IDatabaseServices dbServices, ITableSourceInfo source, IDataReader reader)
        {
            TableSource          = source;
            Name                 = (string)reader["constraint_name"];
            ColumnName           = (string)reader["source_column_name"];
            IsCascadeDelete      = "DELETE".Equals(((string)reader["delete_rule"]).ToUpper());
            ReferencedColumnName = (string)reader["dest_column_name"];

            ReferencedTableSource = new PGTableSource(dbServices, source.Database, (string)reader["dest_table_name"]);
        }