Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mapping custom enum classes with Fluent Nhibernate

Reading some posts from Jimmy Boggard and wondering - how exactly is it possible to map those beasts with fluent nhibernate?

How mapping would look like for this?

public class EmployeeType : Enumeration{
    public static readonly EmployeeType 
     Manager = new EmployeeType(0, "Manager"),
     Servant = new EmployeeType(1, "Servant"),
     AssistantToTheRegionalManager = new EmployeeType
       (2, "Assistant to the Regional Manager");

    private EmployeeType() { }
    private EmployeeType(int value, string displayName) : 
        base(value, displayName) { }
}
like image 752
Arnis Lapsa Avatar asked Oct 20 '09 10:10

Arnis Lapsa


1 Answers

Ah... it was easy. In CodeCampServer - there's a generic EnumerationType class. Idea is simple - we just need to wrap our domain model enumeration value object with EnumerationType in order to map it as integer (or anything else if necessary).

like image 147
Arnis Lapsa Avatar answered Oct 27 '22 21:10

Arnis Lapsa