How do you map an enum as an int value with fluent NHibernate?

fluent-nhibernate, nhibernate

Solution

The way to define this convention changed sometimes ago, it's now :

public class EnumConvention : IUserTypeConvention
{
    public void Accept(IAcceptanceCriteria<IPropertyInspector> criteria)
    {
        criteria.Expect(x => x.Property.PropertyType.IsEnum);
    }

    public void Apply(IPropertyInstance target)
    {
        target.CustomType(target.Property.PropertyType);
    }
}

Problem

Question says it all really, the default is for it to map as a `string` but I need it to map as an `int`. I'm currently using `PersistenceModel` for setting my conventions if that makes any difference. Update Found that getting onto the latest version of the code from the trunk resolved my woes.

Original source

Related problems