title: Map Enum as Int with Fluent NHibernate and NHibernate 3
body: <p>I used this <a href="https://stackoverflow.com/questions/439003/how-do-you-map-an-enum-as-an-int-value-with-fluent-nhibernate">How do you map an enum as an int value with fluent NHibernate?</a> to map in the past but I've recently upgraded to NHibernate 3 and this doesn't seem to work anymore. I've put breakpoints in my EnumConvention class and they're not being hit. The query that is hitting the database has the enum as a string which is the default configuration.</p>
  
  <p>How does this work with NHibernate 3?</p>
  
  <p><strong>Update</strong></p>
  
  <p>Here is part of the mapping file that is generated:</p>
  
  <pre><code>&lt;property name="ComponentType" type="FluentNHibernate.Mapping.GenericEnumMapper`1[[...ComponentType, ..., Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], FluentNHibernate, Version=1.1.0.0, Culture=neutral, PublicKeyToken=8aa435e3cb308880"&gt;
    &lt;column name="ComponentTypeId" /&gt;
  &lt;/property&gt;
  </code></pre>
  
  <p>It doesn't seem right that it would be using a <code>GenericEnumMapper</code> when an <code>IUserTypeConvention</code> is specified for enums.</p>
  
  <p>Here is my convention:</p>
  
  <pre><code>public class EnumConvention : IUserTypeConvention
  {
      public void Accept( IAcceptanceCriteria&lt;IPropertyInspector&gt; criteria )
      {
          criteria.Expect( e =&gt; e.Property.PropertyType.IsEnum );
      }
  
      public void Apply( IPropertyInstance instance )
      {
          instance.CustomType( instance.Property.PropertyType );
      }
  }
  </code></pre>