This NHibernate blog entry notes how detached QueryOver
queries (analogous to DetachedCriteria
) can be created (using QueryOver.Of<T>()
). However, looking this over, it doesn't look analogous to me at all.
With DetachedCriteria, I would create my instance and set it up however I need, and afterwards call GetExecutableCriteria()
to then assign the session and execute the query. With the "detached" QueryOver
, most of the API is unavailable (ie, to add restrictions, joins, ordering, etc...) until I call GetExecutableQueryOver
, which requires takes an ISession
or IStatelessSession
, at which point you are no longer disconnected.
How do you work with detached QueryOver
instances?
EDIT:
Actual problem was related to how I'm storing the detached QueryOver instance:
public class CriteriaQuery<T>
{
internal protected QueryOver<T> _QueryOver { get; set; }
public CriteriaQuery()
{
_QueryOver = QueryOver.Of<T>();
}
// Snip
}
It should be a QueryOver<T, T>
.
QueryOver<T>
doesn't have the API I was expecting;QueryOver<T, T>
is what I needed. – Medlar