Fluent NHibernate - Unable to parse integer as enum.
- by Aaron Smith
I have a column mapped to an enum with a convention set up to map this as an integer to the database.
When I run the code to pull the data from the database I get the error
"Can't Parse 4 as Status"
public class Provider:Entity<Provider> {
public virtual Enums.ProviderStatus Status { get; set; }
}
public class ProviderMap:ClassMap<Provider> {
public ProviderMap() {
Map(x => x.Status);
}
}
class EnumConvention:IUserTypeConvention {
public void Accept(IAcceptanceCriteria<IPropertyInspector> criteria) {
criteria.Expect(x => x.Property.PropertyType.IsEnum);
}
public void Apply(IPropertyInstance instance) {
instance.CustomType(instance.Property.PropertyType);
}
}
Any idea what I'm doing wrong?