title: Mapping Enums to Database with NHibernate/Castle ActiveRecord
body: <p>There's a few other posts on mapping Enums to the DB with ActiveRecord, but none of them answer my question.  I have an enum called OrderState:</p>
  
  <pre><code>public enum OrderState {InQueue, Ordered, Error, Cancelled}
  </code></pre>
  
  <p>And I have the following property on the table:</p>
  
  <pre><code>[Property(NotNull = true, SqlType = "orderstate", ColumnType = "DB.EnumMapper, WebSite")]
  public OrderState State
  {
     get { return state; }
     set { state = value; }
  }
  </code></pre>
  
  <p>And I have the following type class:</p>
  
  <pre><code>public class EnumMapper : NHibernate.Type.EnumStringType&lt;OrderState&gt;
  {
     public EnumMapper()
     {
     }
  
     public override NHibernate.SqlTypes.SqlType SqlType
     {
        get
        {
           return new NHibernate.SqlTypes.SqlType(DbType.Object);
        }
     }
  }
  </code></pre>
  
  <p>Now this actually works the way I want, but the problem is I have tons of enums and I don't want to create a EnumMapper class for each one of them.  Isn't there some way to just tell ActiveRecord to use DbType.Object for any enum?  It seems to either want to be an integer or a string, but nothing else.  This one's been driving me crazy for the last 2 hours..</p>
  
  <p>Mike</p>