Ciao!
I've reproduced the issue there:
https://github.com/lucax88x/dapper-bug
So, if you have a postgresql db, and you use a jsonb column, and you use netwonsoft as deserializer such as:
NpgsqlConnection.GlobalTypeMapper.UseJsonNet(settings:settings);
and perform a a query like
awaitconn.QueryFirstOrDefaultAsync<string>("select \"Content\" from public.\"Posts\"");will throw an exception with
---> System.InvalidCastException:Objectmust implement IConvertible.
at System.Convert.ChangeType(Objectvalue,TypeconversionType,IFormatProviderprovider)
at Dapper.SqlMapper.GetValue[T](DbDataReaderreader,TypeeffectiveType,Objectval) in /_/Dapper/SqlMapper.cs:line 1366---End of inner exception stack trace ---atDapper.SqlMapper.ThrowDataException(Exceptionex,Int32index,IDataReaderreader,Objectvalue) in /_/Dapper/SqlMapper.cs:line3928
at Dapper.SqlMapper.QueryRowAsync[T](IDbConnection cnn, Row row, Type effectiveType, CommandDefinition command)in/_/Dapper/SqlMapper.Async.cs:line 496
This happens only with 2.1.*, if I revert to 2.0.151 everything works perfectly.
This is probably the PR that breaks it.
ps: without json.net it also work perfectly, it's just a combination of json.net and jsonb.
Ciao!
I've reproduced the issue there:
https://github.com/lucax88x/dapper-bug
So, if you have a postgresql db, and you use a jsonb column, and you use netwonsoft as deserializer such as:
and perform a a query like
will throw an exception with
This happens only with 2.1.*, if I revert to 2.0.151 everything works perfectly.
This is probably the PR that breaks it.
ps: without json.net it also work perfectly, it's just a combination of json.net and jsonb.