Hi,
I have the following problem in trying to BulkInsert several entities into a table. The code looks like this:
using (var dapperDb = new NpgsqlConnection(_connectionString))
{
dapperDb.Open();
await dapperDb.BulkActionAsync(x => x.BulkInsert(insert)); // also x.BulkMerge(insert) do the same behaviour
}
'insert' is just a List of 50 Elements with objects of a class with no special stuff inside, just simple data objects like string and int.
After executing the code above, only the last element of that list is inserted into the DB table and no other element. Calling the method again, then the same behaviour applies as described, only the last element is added to the DB table and so on. So I have to call the method 50 times to add all elements which is definitely not intended.
Is there some special option in dapper to get this working with Npgsql? Or do I have to set something special in the PostgreSQL database to get the Bulk methods work?
Versions I used:
PostgreSQL 13.1, compiled by Visual C++ build 1914, 64-bit
Npgsql.EntityFrameworkCore.PostgreSQL Version 3.1.4
Hi, I have the following problem in trying to BulkInsert several entities into a table. The code looks like this:
'insert' is just a List of 50 Elements with objects of a class with no special stuff inside, just simple data objects like string and int.
After executing the code above, only the last element of that list is inserted into the DB table and no other element. Calling the method again, then the same behaviour applies as described, only the last element is added to the DB table and so on. So I have to call the method 50 times to add all elements which is definitely not intended.
Is there some special option in dapper to get this working with Npgsql? Or do I have to set something special in the PostgreSQL database to get the Bulk methods work?
Versions I used: