Q:

How do i remove/undo .SetMaxResults(n) / .SetFirstResult(n) from a nHibernate criteria query?

Is there a way to remove/undo .SetMaxResults() / .SetFirstResults() from a already constructed DetachedCriteria?
Can it be done without changing the original DetachedCriteria?

A:

yes you can remove/undo this by setting its value to "-1", nHibernate internally uses the static value NHibernate.Engine.RowSelection.NoValue
criteria.SetMaxResults(NHibernate.Engine.RowSelection.NoValue);
criteria.SetFirstResult(NHibernate.Engine.RowSelection.NoValue);

if you want to keep your original DetachedCriteria you need to create a clone before changing .SetMaxResults / .SetFirstResult
 DetachedCriteria clonedCriteria = NHibernate.CriteriaTransformer.Clone(originalCriteria)
                 .SetMaxResults(NHibernate.Engine.RowSelection.NoValue)
                 .SetFirstResult(NHibernate.Engine.RowSelection.NoValue);

