Problem using FluentNHibernate, SQLite and Enums

Posted by weenet on Stack Overflow See other posts from Stack Overflow or by weenet
Published on 2010-06-08T21:59:35Z Indexed on 2010/06/08 22:02 UTC
Read the original article Hit count: 343

Filed under:
|

I have a Sharp Architecture based app using Fluent NHibernate with Automapping. I have the following Enum:

    public enum Topics
    {
        AdditionSubtraction = 1,
        MultiplicationDivision = 2,
        DecimalsFractions = 3
    }

and the following Class:

    public class Strategy : BaseEntity
    {
        public virtual string Name { get; set; }
        public virtual Topics Topic { get; set; }
        public virtual IList Items { get; set; }

    }

If I create an instance of the class thusly:

Strategy s = new Strategy { Name = "Test", Topic = Topics.AdditionSubtraction };

it Saves correctly (thanks to this mapping convention:

    public class EnumConvention : IPropertyConvention, IPropertyConventionAcceptance
    {
        public void Apply(FluentNHibernate.Conventions.Instances.IPropertyInstance instance)
        {
            instance.CustomType(instance.Property.PropertyType); 
        }

        public void Accept(FluentNHibernate.Conventions.AcceptanceCriteria.IAcceptanceCriteria criteria)
        {
            criteria.Expect(x => x.Property.PropertyType.IsEnum); 
        }
    }

However, upon retrieval, I get an error regarding an attempt to convert Int64 to Topics.

This works fine in SQL Server.

Any ideas for a workaround?

Thanks.

© Stack Overflow or respective owner

Related posts about sqlite

Related posts about fluent-nhibernate