Releases for RepoDb.EnterpriseDb.BulkOperations
View the NuGet package here or download it directly here.
RepoDb.EnterpriseDb.BulkOperations (v0.0.1-alpha) - Preview
Released: TBA
New
First release of the bulk operations extension for RepoDb.EnterpriseDb. Targets .NET 8, .NET 9, and .NET 10.
Architectural note: rows are staged through a pseudo (staging) table and loaded via
RepoDb.Connector.EnterpriseDb’sEDBBulkCopy, itself built on Npgsql’s native binaryCOPYprotocol — a genuine bulk load, not a row-by-row loop.
What’s included
- BulkInsert, BulkMerge, BulkUpdate, BulkDelete and BulkDeleteByKey, each with an
Asyncoverload, callable against anEDBConnectionwith an entity list, aDataTable, or anIDataReader(BulkDeleteByKeytakes a target table name and a list of primary key values directly, rather than an entity type parameter). EDBBulkImportIdentityBehavior(KeepIdentitydefault,ReturnIdentity) — controls whether identity values are sent as-is or read back after BulkInsert/BulkMerge.ReturnIdentityforBulkMergepre-assigns identities to unmatched rows vianextval(pg_get_serial_sequence(...))before anON CONFLICT DO UPDATEupsert; forBulkInsertit inserts straight from the pseudo table with aRETURNINGclause.EDBBulkImportPseudoTableType(Auto,Memory,Physical) — selects the staging-table strategy backing every operation;Memorycreates a genuine session-scopedTEMPtable,Physicalan ordinary heap table under a deterministic name.- EDBBulkInsertMapItem — explicit source-to-destination column mapping, with an optional
EDBTypeoverride. Explicit mappings are type-checked up front: an incompatible source/destination CLR type pairing (other than the allowedGuid↔stringand integral-to-integral widenings) throws anInvalidTypeExceptionimmediately, rather than failing inside EnterpriseDB. - EDBTraceKeys — the tracing key constants for the five bulk operations, for use with ITrace.
BulkMerge(KeepIdentity) uses a two-statement cascade — anUPDATE ... FROMfor matched rows, thenINSERT ... WHERE NOT EXISTS (...)for unmatched ones.BulkMerge(ReturnIdentity) instead pre-assigns identities and runs a singleINSERT ... ON CONFLICT DO UPDATE ... RETURNING.BulkUpdateuses a correlatedUPDATE ... FROM "PseudoTable" S WHERE (...)form.BulkDelete/BulkDeleteByKeyuseDELETE ... USING "PseudoTable" S WHERE (...).- Every pseudo table gets an identity
__RepoDbBulkRowOrder__column recording each row’s original load order, used to align generated identity values back onto the correct entity/DataRowafter BulkInsert/BulkMerge withReturnIdentity. - Explicit column mappings are type-checked against the target table’s DbField types before the write begins (
Guid↔stringand integral-to-integral widenings allowed), throwingInvalidTypeExceptionup front on a mismatch. - Referenced the
RepoDbpackagev1.16.0. - Referenced the
RepoDb.EnterpriseDbpackagev0.0.1-alpha. - Referenced the
RepoDb.Connector.EnterpriseDbpackagev0.0.1-alpha2.
Known limitations (v1)
- Pseudo table names are deterministic, not per-call-unique — built from the
pseudoTableType, the target table name, and the operation (e.g.PhysicalPersonMerge). Two concurrent bulk calls of the same operation against the same table, both resolving to the samepseudoTableType, can interfere with each other’s staged rows. PreferMemory(a genuine per-sessionTEMPtable) overPhysicalwhen running concurrent bulk operations from different connections against the same table. - The
DbDataReaderoverloads ofBulkInsertandBulkMergehave noidentityBehaviorargument — a forward-only, single-pass reader cannot be rewound to correlate generated identity values back onto a source row. BulkDeleteByKeytakes atableNamestring directly (BulkDeleteByKey<TPrimaryKey>(connection, tableName, primaryKeys, ...)) rather than an entity type parameter.- This package inherits every Known limitation of RepoDb.EnterpriseDb itself (e.g. no table hints).