Hi
I am currently upgrading our application to NHibernate 1.2 but have encountered a problem that I could do with some help with.
I need to create an ICriteria object and do a RowCount on this (for use with a pager). I then need to add a sort to this ICriteria and select just 12 rows (start position depending on the selected page). The problem I seem to be having is that once I have added Projection.RowCount() to the ICriteria I am unable to remove this RowCount. Does anyone know of a way to remove Projections?
I've been told to use CriteriaTransformer.TransformToRowCount() but CriteriaTransformer seems to be an NHibernate 2.0 feature as I do not have it available.
I have supplied some example code to hopefully help explain what I need.
Code:
ICriteria q = m_Query;
SearchContainer s = new SearchContainer();
s.Count = (int)q.SetProjection(Projections.ProjectionList().Add(Projections.RowCount())).UniqueResult<int>();
m_Pages = (int)s.Count;
// I need to clear the ProjectionList at this point
q = GetSort(q, this.m_Sort, this.m_SortDir);
q.SetMaxResults(m_VehiclesPerPage);
q.SetFirstResult(m_CurrentStartPage);
m_Vehicles = q.List();
Any assistance would be gratefully appreciated.
Cheers