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" ...>
<class name="OrdenDeCompra" table="ordenDeCompra" lazy="false">
<id name="Id" column="id_ordenDeCompra" type="Int32">
<generator class="increment" />
</id>
...
<property name="EnumType" column="id_enum"
type="Int32" not-null="true" />
...
</class>
</hibernate-mapping>
How do I do search by Enum?