zzzprojects / Dapper-Plus

Dapper Plus - High-Efficient Bulk Actions (Insert, Update, Delete, and Merge) for .NET
https://dapper-plus.net/
383 stars 85 forks source link

BulkInsert/BulkMerge in combination with Npgsql (PostgreSQL) has weird behaviour #75

Closed isenmann closed 3 years ago

isenmann commented 3 years ago

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:

isenmann commented 3 years ago

I posted the issue here: https://github.com/zzzprojects/Bulk-Operations/issues/59