How to use ICriteria with Enum properties in NHibernate
问题 Hi I want to write a FindByExample(object o) method. So I tried this: public IList<T> FindByExample(T o) { return Session.CreateCriteria(typeof(T)).Add(Example.Create(o)).List<T>(); } (It's in a generic class) It should work fine, but if T has a property of an enum type, it throws this exception: "Type mismatch in NHibernate.Criterion.SimpleExpression: EnumProperty expected type System.Int32, actual type EnumType" The mapping is this: <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" ...>