tags:

views:

34

answers:

0

Hello there,

I have a column called TemplateType mapped as follows in my NHibernate library:

Map(x => x.TemplateType).Not.Nullable().CustomType(typeof(TemplateType)); //x is an instance of type <Template>

So, is mapped to an int column in the database table: Template

Now when I am trying to get list of Template objects filtered with TemplayeType value as

    public List<Template> ListTemplatesByTemplateType(int userId, TemplateType templateType)
    {
        List<Template> templates = new List<Template>();

        using (ISession session = SessionManagerSingleton.GetSession())
        {
            using (ITransaction tx = session.BeginTransaction())
            {
                try
                {
                    templates = (session.Linq<Template>().Where(x => x.TemplateType == templateType)).ToList<Template>();
                    tx.Commit();
                }
                catch (Exception ex)
                {
                    tx.Rollback();
                }
            }
        }
        return templates;
    }

I am getting error:
Could not understand: (ConvertChecked([1003]) = 2)

Please guide.

PS: Error is occuring due to Where condition while fetching Templates