Problem using FluentNHibernate, SQLite and Enums
- by weenet
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.