Skip to content

pet-toys/db-assistant-postgres

Database Assistant (Postgres)

Unit Test NuGet Version NuGet Downloads

promotion

DbAssistant.Postgres is the open source .net library with nice wrappers for Ngsql.

Key features:

  • High-performance insertion of large data into a table (COPY table(column definitions) FROM STDIN BINARY; feature)
    • Accepts IEnumerable<TEntity> and IAsyncEnumerable<TEntity>
    • Supports mapping of entity properties to table columns (e.g. MapJson, MapMoney, MapTimeStamp, etc.)
    • For better performance, it is recommended to insert data into a temporary table that has no indexes or keys. After that, you can copy data from the temporary table to the target table.

Usage

using PetToys.DbAssistant.Postgres;

await using var connection = new NpgsqlConnection(connectionString);
var result = await connection.CreateBulkContext<BusinessEntity>("table_name")
            .MapJson("column_json", entity => entity.Data)
            .MapMoney("column_money", entity => entity.Money)
            /* ... */
            .InsertAsync(entities);

Roadmap:

  • High-performance binary import/export between table and stream (coming soon)
  • CSV import/export (may be)
  • There may be something else

This package is created for my own needs. Requests for additional functionality and pull requests are welcome.


Provided under the Apache License, Version 2.0.

About

Postgres DB Assistant.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Languages