Dapper enum mapping

.net dapper

Question

I need help for mapping enums with Dapper and Oracle.

I have a field in Oracle type NUMBER (1) and must turn into an enum in my entity.

public Status Status { get; set; }

Status is a enum:

public enum Status
{
    [Description("Inactive", "0")]
    Inactive = 0,

    [Description("Active", "1")]
    Active = 1,
 }

How to make the mapping using Dapper?

Expert Answer

Enums should JustWorkâ„¢ for either integer or string representations. If it isn't working, you'll have to be more specific about any exception that it is throwing. For example, thinking aloud and pure speculation, but: IIRC Oracle has a habit of wanting to great numbers as 64-bit, and I wonder if the ebun mapping code handles all flavors of numeric conversion. If it doesn't, then that's a bug.

So: does it work?



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