Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Dapper support Enums?

Tags:

c#

orm

dapper

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);
like image 608
Sergey Avatar asked May 10 '13 10:05

Sergey


1 Answers

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?

like image 189
Marc Gravell Avatar answered Oct 05 '22 18:10

Marc Gravell