Open Kudiyarasu26 opened 1 year ago
I just ran into this myself. This comes from the library trying to update your DTO with the inserted identity. It assumes the identity is a long
:
https://github.com/tmsmith/Dapper-Extensions/blob/master/DapperExtensions/DapperImplementor.cs#L613
So when it tries to update your DTO to set the identity value, it throws that exception: https://github.com/tmsmith/Dapper-Extensions/blob/master/DapperExtensions/DapperImplementor.cs#L710
This means it successfully inserted the item (which is why you saw it in the table), but throws an exception processing the result.
I've seen on StackOverflow that the general advise seems to be to use a different key type in your table, such as a GUID or BIGINT.
To anyone thinking of submitting a PR for this, keep in mind that every SQL Dialect may need to be updated too. For instance, the SqlServerDialect casts the scope identity to a bigint: https://github.com/tmsmith/Dapper-Extensions/blob/master/DapperExtensions/Sql/SqlServerDialect.cs#L23
Object of type 'System.Int64' cannot be converted to type 'System.Int32 Show this type of the Error But Values Insert In Table