Dapper conversion of TinyInt

asp.net-mvc-3 c# dapper mvc-mini-profiler mysql

Question

I'm attempting to write my own DatabaseStorageBase for mini-profiler, and I'm running into issues in my

private List<T> LoadFor<T>(DbConnection conn, object idParameter)

method. Dapper keeps yelling at me with

Error parsing column 5 (level=0 - SByte)

I'm storing level as tinyint(4), so I'm assuming dapper cannot make the conversion from Tiny Int to what looks like an Enum (ProfileLevel)? Could someone suggest how I should store the level in mysql so I can solve my conversion woes?

Popular Answer

Wow. what a cool insident, I'm also implement my own mysqlstorage for miniprofiler and get similar error with you.

miniprofiler uses enum as byte for MiniProfiler.Level and SqlTiming.ExecuteType using tinyint datatype for this property return invalid cast which shown that it return Sbyte instead of byte. this behavior default behavior of mysql as it permit return of signed value of tinyint where as sqlserver not as mention here:

http://forums.mysql.com/read.php?38,5524,5581#msg-5581

http://social.msdn.microsoft.com/Forums/br/adonetefx/thread/8b0949ba-03e8-4637-baa1-d2b4ff0771f0

Therefore, the resolution is simply by alter the tinyint field of level and executeType into unsigned tinyint will return correct value (cast to byte). now my mysqlstorage working as expected.. hope can ask pull request to sam :)




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