Dapper icon indicating copy to clipboard operation
Dapper copied to clipboard

Some strings can be cast as decimals and cause an overflow error

Open pingu2k4 opened this issue 3 years ago • 0 comments

I have an open SO thread on this, but after whittling it down to just a small amount of work (a basic select statement), I am more and more certain this is a bug with Dapper than something I have done wrong. (https://stackoverflow.com/questions/71698644/dapper-orm-some-db-values-returned-are-assessed-as-decimals-when-they-are-stri)

(I am using a SQL DB) I have a table, which has a column [To], which is of type NVARCHAR(42). If I SELECT this column, it usually works fine and my DTO, has the To property defined as a string.

There is one row which is causing issues however. When I try and SELECT it, I get the error Error parsing column 4(Value=0x942931035c59664564951677019130446debc886 - String). An inner exception shows as "Conversion overflows.", which appears to be coming from some get_Decimal() method.

The value in that column on the problematic row is 0x942931035c59664564951677019130446debc886.

To replicate, create a table with an NVARCHAR(42) column, and insert the above value. Then try and SELECT it, and convert to a DTO where the matching column is a string.

image

pingu2k4 avatar Mar 31 '22 22:03 pingu2k4