I usually perform a count on my criteria before performing any paging.
That way I issue two selects, one for the resultset count and another
for the actual resultset.
Normally I do something like this:
public IEnumerable<ResultObject> GetPagedResultSet(out int count,
QueryRange range, params Order[] orders) {
var criteria = currentSession.CreateCriteria(typeof(ResultObject))
.SetProjection(Projections.Count(Projections.Id()));
count = criteria.UniqueResult<int>();
criteria.SetProjection(null);
if(!QueryRange.IsNullOrEmpty(range)) {
range.Apply(criteria);
}
if(orders != null) {
foreach(var order in orders) {
criteria.AddOrder(order);
}
}
return criteria.List<ResultObject
}
The code above is from memory, and might be subject to your own
changes :)
Furthermore the QueryRange class is one I have created to ease the
paging. I can post the code for it, if you'd like.
On 10 Mar., 17:33, Robin Nadeau <[email protected]> wrote:
> Is there a way to get the item count from the dataset when doing paging?
>
> --
> Robin Nadeau, B.Eng.
> Software Developer
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---