6
votes

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?

2
it should work out of the box, could you please post the code ? - Felice Pollano
I found the problem. The stored procedure was using coalesce on the column which was casting it as an int. I would delete this question but I don't know how. - user1466918
I don't think is a good idea to delete the question since it is useful as a reference. - Felice Pollano

2 Answers

3
votes

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

2
votes

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