Exemple #1
0
        internal static PGSchema GetSchema(string schemaName)
        {
            PGSchema schema = new PGSchema();

            string sql = FileHelper.ReadSqlResource("schema.sql");

            using (NpgsqlCommand command = new NpgsqlCommand(sql))
            {
                command.Parameters.AddWithValue("@SchemaName", schemaName);
                using (DataTable table = DbOperation.GetDataTable(command))
                {
                    if (table.Rows.Count.Equals(1))
                    {
                        schema.Name        = schemaName;
                        schema.Owner       = Conversion.TryCastString(table.Rows[0]["owner"]);
                        schema.Description = Conversion.TryCastString(table.Rows[0]["description"]);
                    }
                }
            }

            schema.Tables            = TableProcessor.GetTables(schemaName);
            schema.Views             = ViewProcessor.GetViews(schemaName);
            schema.Functions         = FunctionProcessor.GetFunctions(schemaName);
            schema.TriggerFunctions  = TriggerFunctionProcessor.GetTriggerFunctions(schemaName);
            schema.MaterializedViews = MaterializedViewProcessor.GetMaterializedViews(schemaName);
            schema.Sequences         = SequenceProcessor.GetSequences(schemaName);
            schema.Types             = TypeProcessor.GetTypes(schemaName);

            return(schema);
        }
Exemple #2
0
        internal static Collection <PgFunction> GetTriggerFunctions(string schemaPattern = ".*", string xSchemaPattern = "")
        {
            string sql = FileHelper.ReadSqlResource("trigger-functions-by-schema.sql");

            using (NpgsqlCommand command = new NpgsqlCommand(sql))
            {
                command.Parameters.AddWithValue("@SchemaPattern", schemaPattern);
                command.Parameters.AddWithValue("@xSchemaPattern", xSchemaPattern);
                return(FunctionProcessor.GetFunctions(DbOperation.GetDataTable(command)));
            }
        }