Batch Operations

Packing thousands of single-row statements into a handful of round trips, without changing a single call site.

What it is

InsertAll, UpdateAll, and MergeAll pack multiple single-row statements into one call and execute them together, wrapped in an implicit transaction if you didn’t supply one yourself.

var customers = GetCustomers(1000);
connection.InsertAll<Customer>(customers, batchSize: 100);

Identity alignment

Because rows travel in packed statements rather than one at a time, the library adds a hidden __RepoDb_OrderColumn parameter to track each entity’s original position, so a newly generated identity value always lands back on the correct object in your collection.

Tuning the batch size

The default batchSize is 10; raising it trades fewer round trips for larger packed statements. On SQL Server, ADO.NET’s 2100-parameter ceiling puts a hard cap on how high you can go, so wide tables need a smaller batch.

When to reach for it

Batch operations are the default choice for pushing more than a handful of rows. Past roughly a thousand rows, a native bulk-copy operation starts winning on raw throughput.