DbAssistant.Postgres is the open source .net library with nice wrappers for Ngsql.
- High-performance insertion of large data into a table (
COPY table(column definitions) FROM STDIN BINARY;
feature)- Accepts
IEnumerable<TEntity>
andIAsyncEnumerable<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.
- Accepts
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);
- 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.