views:

1491

answers:

2

I found an example of implementing the repository pattern in NHibernate on the web, and one of the methods uses this code to get the first result of a query:

public IEnumerable<T> FindAll(DetachedCriteria criteria, int firstResult, int numberOfResults, params Order[] orders)

{
    criteria.SetFirstResult(firstResult).SetMaxResults(numberOfResults);
    return FindAll(criteria, orders);
}

But VS intellisense isn't picking up this method from DetachedCriteria. Does anyone know if this is possible with DetachedCriteria? I'm using NHibernate version 1.2.1.

A: 

never mind, I think I got it:

criteria.GetExecutableCriteria(_session).SetFirstResult(firstResult).SetMaxResults(numberOfResults);
Mark Struzinski
A: 

It doesn't seem to be available until an ISession is bound. For instance, it's not on DetachedCriteria, but it is available on the ICriteria that is returned from the GetExecutableCriteria method.

Ryan Duffield
That makes sense. Thanks for the insight.
Mark Struzinski