views:

439

answers:

2

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");
    public static readonly EmployeeType Servant 
        = new EmployeeType(1, "Servant");
    public static readonly EmployeeType AssistantToTheRegionalManager 
        = new EmployeeType(2, "Assistant to the Regional Manager");

    private EmployeeType() { }
    private EmployeeType(int value, string displayName) : 
        base(value, displayName) { }
}
+1  A: 

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).

Arnis L.
+1 thanks, and for anyone who wants it you can find it here: http://code.google.com/p/codecampserver/source/browse/trunk/src/Infrastructure/EnumerationType.cs
rohancragg
Quintin Par
Thanks for fixing it. They changed project structure a bit.
Arnis L.
A: 

You can also create derive from IUserType and specify how to store an retrieve the information from a specific column on the database, serializing and deserializing the enumeration.

Check this article for a simple explanation of the basics of IUserType.

Marc Climent