Dapper can't map bit columns to boolean fields

dapper

Question

I have a bit column in the SQL Server 2008 database and I am trying to use Dapper to map it to my object that has boolean fields that match the bit columns. I get invalid cast exceptions as Dapper is trying to say the columns are ints. How do I get it to map a bit to a bool? Also, will there ever be decent documentation for this ORM?

Accepted Answer

I found the problem. The stored procedure was using coalesce on the column which was casting it as an int.


Popular Answer

Is the column nullable ? If this is the case try to structure the dto with a property of type bool? instaead of just bool, to handle correctly the DbNull value. The better documentation is the code itself and the project home.




Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why