How can I create a query for a custom IUserType field in NHibernate?
More specifically: I am working on a brown box application. I have a field in the database called "State" that contains a char representing what state this object is in.
In my code, I want this to be represented as an enumeration, so I created an enumeration with a value for each state and created an IUserType that converts from the db char value to my enum and back for selection and updating.
I want to build a query that looks something like this:
session.CreateCriteria<MyType>().Add(Expression.Eq("State", StateEnum.Complete))
However, this request throws an exception:
could not resolve property: State of: MyNamespace.MyType
presumably because NHibernate does not know how to make a choice regarding the DB char field specified for the StateEnum type.
c # nhibernate
hackerhasid
source share