Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dapper conversion of TinyInt

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?

like image 310
JesseBuesking Avatar asked Nov 04 '22 07:11

JesseBuesking


1 Answers

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 :)

like image 133
Anton Hasan Avatar answered Nov 09 '22 06:11

Anton Hasan