Dapper mapping MySql BIT(1) data type to ulong instead of boolean

.net dapper mysql

Question

Please has anyone come across the above situation with Dapper and MySQL. In all my tables in MySQL (5.1), where the data type is BIT(1) or BIT, Dapper simply return such field as ulong (UInt64). I am using MySql.Data.MySqlClient and I have no such issue with EF which is what I am trying to convert from.

Thanks for any help.

Popular Answer

In MySQL, the type Boolean is mapped to Tinyint(1) with MySQL. Perhaps you will have to cast it to Boolean (0=false/1=true), Convert.toBoolean(UInt64) may help you (see http://msdn.microsoft.com/en-us/library/33f2zy48.aspx).

@Christian Droulers: The behaviour of SQLite is similar.




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