Does Dapper support Enums?

c# dapper orm

Question

I have a class User where Role is enum with values: Employee, Admin etc... Dapper throws an exception: "The member Role of type System.Enum cannot be used as a parameter value"

Does dapper support enums?

    IDbConnection connection
connection.Execute(sb.ToString(), entityToInsert, /*transaction: transaction*/tx, commandTimeout: commandTimeout);

Accepted Answer

Enums are supported, but Enum isn't :p

So if you have:

class User {
    public MemberRole Role {get;set;}
}

then that should work fine; however

class User {
    public Enum Role {get;set;}
}

will not. Are you perhaps using the latter?



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