views:

232

answers:

1

Why are enums mapped as strings and not as ints when using automapper in Fluent NHibernate?

A: 

thanks to Mikael Henriksson at the fluent-nhibernate mailing list i found the answer:

public class EnumConvention :
    IPropertyConvention,
    IPropertyConventionAcceptance
{
    #region IPropertyConvention Members

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

    #endregion

    #region IPropertyConventionAcceptance Members

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

    #endregion

}
Carl Hörberg