zzzprojects / Bulk-Operations

C# SQL Bulk Operations | High-performance C# bulk insert, update, delete and merge for SQL Server, SQL Azure, SQL Compact, MySQL, and SQLite.
https://bulk-operations.net
142 stars 36 forks source link

Error in Bulk Merge While Using ZonedDateTime Property for Dapper Plus #66

Closed Jaanzaib closed 3 years ago

Jaanzaib commented 3 years ago

Hi, I have a class with a NodaTime.ZonedDateTime Property like below.

public class Reservation
{
    public ZonedDateTime BookedOnDate { get; set; }
}

I am using Dapper Plus Bulk Merge to store data into postgres database like below.

    public async Task UpdateReservationsAsync(IEnumerable<Reservation> reservations)
    {
        using (var connection = _connectionFactory.GetPostgresServerConnection())
        {
            await connection.BulkActionAsync(x => x.BulkMerge(reservations));
        }
    }

before that i am adding the support for above property like below in Startup.cs file

DapperPlusManager.AddCustomSupportedType(typeof(NodaTime.ZonedDateTime));

Running the code gives me the following exception. pgsql column data type is timestamptz

System.InvalidCastException: 'Can't write CLR type NodaTime.ZonedDateTime with handler type TimestampHandler'

Please note that it works fine for Bulk Insert but gives exception for Bulk Merge.

Any help would be appreciated.

JonathanMagnan commented 3 years ago

Thank you for reporting,

We will look at it.

JonathanMagnan commented 3 years ago

Hello @Jaanzaib ,

A new version has been released.

By developed made a few change to better support this kind of special type.

Could you try it and let us know if everything works correctly?

Best Regards,

Jon