Skip to content

Repository files navigation

Pure.RelationalSchema.Storage.PostgreSQL

PostgreSQL storage implementation for the Pure relational schema ecosystem — creates schemas, manages tables, and reads/writes rows via IDbConnection.

.NET build & testpublish NuGetNuGetLicense: MIT

Overview

Pure.RelationalSchema.Storage.PostgreSQL bridges the abstract relational model defined in Pure.RelationalSchema with a live PostgreSQL database. It provides:

  • DDL executionPostgreSqlCreatedSchema lazily generates and executes CREATE SCHEMA, CREATE TABLE, CREATE INDEX, and ALTER TABLE … ADD CONSTRAINT statements derived from an ISchema.
  • Row accessPostgreSqlStoredTableDataSet exposes table rows as both IQueryable<IRow> and IAsyncEnumerable<IRow> via SELECT * queries.
  • Row insertionPostgreSqlStoredSchemaDataSetWithInsertedRows / PostgreSqlStoredTableDataSetWithInsertedData execute INSERT INTO statements and surface the inserted rows alongside existing ones.

Schema and table identifiers are derived from hash codes (via Pure.RelationalSchema.HashCodes) to avoid name-length and special-character constraints in PostgreSQL.

Public API

TypeKindDescription
IPostgreSqlStoredSchemaDataSetinterfaceExtends IStoredSchemaDataSet with an IDbConnection Connection property
PostgreSqlStoredSchemaDataSetrecordMaps each ITable in an ISchema to a PostgreSqlStoredTableDataSet; implements IPostgreSqlStoredSchemaDataSet
PostgreSqlStoredSchemaDataSetWithInsertedRowsrecordWraps an IPostgreSqlStoredSchemaDataSet and inserts grouped IRow data into the corresponding table datasets
PostgreSqlCreatedSchemarecordISchema decorator that executes DDL lazily on first property access
PostgreSqlStoredTableDataSetrecordIStoredTableDataSet backed by a PostgreSQL table; supports sync and async enumeration
PostgreSqlStoredTableDataSetWithInsertedDatarecordWraps a table dataset and inserts rows on first enumeration
PostgreSqlColumnTypeNameclassMaps Pure schema column types to PostgreSQL type name strings

Dependencies

Target Frameworks

  • .NET 8
  • .NET 9
  • .NET 10

Installation

dotnet add package Pure.RelationalSchema.Storage.PostgreSQL

Usage

usingSystem.Data;usingNpgsql;usingPure.RelationalSchema.Storage.PostgreSQL;// schema is your ISchema; connection is an open IDbConnectionIDbConnectionconnection=newNpgsqlConnection(connectionString);connection.Open();// Execute DDL lazily on first accessISchemacreatedSchema=newPostgreSqlCreatedSchema(schema,connection);// Build a dataset backed by the created schemaIPostgreSqlStoredSchemaDataSetdataset=newPostgreSqlStoredSchemaDataSet(createdSchema,connection);// Read rows asynchronously from a tableIStoredTableDataSettableDataset=dataset[myTable];awaitforeach(IRowrowintableDataset){objectvalue=row.Cells[myColumn].Value;}// Insert rows grouped by tableIEnumerable<IGrouping<ITable,IRow>>rowGroups=rows.GroupBy(r =>r.Table);IPostgreSqlStoredSchemaDataSetwithInserted=newPostgreSqlStoredSchemaDataSetWithInsertedRows(dataset,rowGroups);

About

PostgreSQL storage implementation for the Pure relational schema ecosystem — DDL execution, row access, and row insertion via IDbConnection.

Resources

Code of conduct

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages

Generated from kudima03/Pure.Template