grennis wrote:
You dont need Ayende's method with 1.2 beta. The built-in generic support works well.
I'm not using Ayende's NHibernate.Generics with 1.2b. Here is simple testcase, that fails with NHibernate.QueryException: the collection was unreferenced.
[TestMethod]
public void TestHibernateFiltering() {
Configuration cfg = new Configuration();
cfg.AddAssembly("Tests");
ISessionFactory factory = cfg.BuildSessionFactory();
ISession s = factory.OpenSession();
try {
IQuery q = s.CreateQuery("from BusinessEntity");
IList<BusinessEntity> list = q.List<BusinessEntity>();
Console.WriteLine(list.Count);
q = s.CreateFilter(list, "where this.IsArchived = false");
// this line fails
Console.WriteLine(q.List<BusinessEntity>().Count);
} finally {
s.Close();
}
}
// the class is trivial
public class BusinessEntity {
private Guid id;
private bool isArchived;
public BusinessEntity() {}
public virtual Guid ID {
get { return id; }
set { id= value; }
}
public virtual bool IsArchived {
get { return isArchived; }
set { isArchived = value; }
}
}
Stack trace is:
at NHibernate.Impl.SessionImpl.GetFilterTranslator(Object collection, String filter, QueryParameters parameters, Boolean scalar)
at NHibernate.Impl.SessionImpl.Filter(Object collection, String filter, QueryParameters parameters, IList results)
at NHibernate.Impl.SessionImpl.Filter[T](Object collection, String filter, QueryParameters parameters)
at NHibernate.Impl.QueryFilterImpl.List[T]()
Any help with it is really appreciated )
BTW: it fails even when using non-generic IQuery.List() method.