Fluent NHibernate - Unable to parse integer as enum.

Posted by Aaron Smith on Stack Overflow See other posts from Stack Overflow or by Aaron Smith
Published on 2010-04-28T16:47:57Z Indexed on 2010/04/28 16:53 UTC
Read the original article Hit count: 430

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?

© Stack Overflow or respective owner

Related posts about nhibernate

Related posts about fluent-nhibernate