# Explicitly casting enums on setters

**URL:** <https://community.miniprofiler.com/t/explicitly-casting-enums-on-setters/125>\
**Category:** uncategorized\
**Created:** [May 30, 2012, 2:39am UTC](https://community.miniprofiler.com/t/explicitly-casting-enums-on-setters/125 "2012-05-30T02:39:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JesseBuesking](https://sea2.discourse-cdn.com/flex016/user_avatar/community.miniprofiler.com/jessebuesking/32/1037_2.png) [@JesseBuesking](https://community.miniprofiler.com/u/JesseBuesking)\
**Post date:** [May 30, 2012, 2:39am UTC](https://community.miniprofiler.com/t/explicitly-casting-enums-on-setters/125/1 "2012-05-30T02:39:45Z")

</div>

Would it be possible to have the enum setter methods explicity do a cast (in MiniProfiler.cs and SqlTiming.cs)? MySql is being a nerd and has difficulties casting from tinyint to Enum.

I’m assuming it would go something like this:

```
private ProfileLevel _level;
/// <summary>
/// Allows filtering of <see cref="Timing"/> steps based on what <see cref="ProfileLevel"/> 
/// the steps are created with.
/// </summary>
[DataMember(Order = 5)]
public ProfileLevel Level
{
    get
    {
        return _level;
    }
    set
    {
        _level = (ProfileLevel)((int)value);
    }
}

```

This would apply to SqlTimings.ExecuteType as well.

Currently I’m using Dapper to pull the data from MySql, and I’m having to map each property by hand in order to handle this casting issue.

---

<div class="post-metadata">

**Author:** ![sam](https://sea2.discourse-cdn.com/flex016/user_avatar/community.miniprofiler.com/sam/32/377_2.png) [@sam](https://community.miniprofiler.com/u/sam)\
**Post date:** [May 30, 2012, 3:52pm UTC](https://community.miniprofiler.com/t/explicitly-casting-enums-on-setters/125/2 "2012-05-30T15:52:57Z")

</div>

what if we added a private ProfileLevelRaw to set and get this (shadow), it would appease Dapper / MySql

---

<div class="post-metadata">

**Author:** ![JesseBuesking](https://sea2.discourse-cdn.com/flex016/user_avatar/community.miniprofiler.com/jessebuesking/32/1037_2.png) [@JesseBuesking](https://community.miniprofiler.com/u/JesseBuesking)\
**Post date:** [May 30, 2012, 4:35pm UTC](https://community.miniprofiler.com/t/explicitly-casting-enums-on-setters/125/3 "2012-05-30T16:35:12Z")

</div>

If one could be added for SqlTimings.ExecuteType as well I’d fly to where you live an give you a hug.

Update nuget with this modification and I’ll purchase you a six-pack of your favorite beverage 😃
