Any way to override with call to GetSqlDecimal for specified column?
I'm in a position where I need to read a column from a SQL Server sproc result with a SQL data type of decimal(38,15). I can't change it in SQL Server, but need to consume it. Of course when I use SqlConnection.Query<T>, I get a "Conversion overflows" exception message on that column.
I tried using a TypeHandler<T> for that column, hoping I could get a SqlDecimal back and I could map it to a custom type we're using (not System.Decimal). This didn't work, because the object passed to Parse is already a decimal. I read the code and see it's because GetValue is called on the reader, filling a SqlBuffer, and SqlBuffer.Decimal throws the OverflowException.
at System.Data.SqlClient.SqlBuffer.get_Decimal()
at System.Data.SqlClient.SqlBuffer.get_Value()
at System.Data.SqlClient.SqlDataReader.GetValue(Int32 i)
at Deserialize1537704b-cb70-4a16-bee7-da18841b08a2(IDataReader )
Is there any way I could get access to the SqlDataReader in the TypeHandler or some other trick I'm not aware of? If not I think I need to break out of Dapper entirely when reading this type. I guess I need an even more custom handler than TypeHandler.
I am running into this same issue. Anyone have any ideas?
investigating and resolving in https://github.com/DapperLib/Dapper/issues/1907