I have read somewhere (can\'t remeber where and how) that NHibernate 3 allows the determination of the total number of records whilst performing a paged query (in one database q
I don't have enough reputation to comment on CodeProgression's solution above...but the proper ONE DB call using QueryOver w/ Future<> is:
var query = session.QueryOver()
.Skip((Page - 1) * PageSize)
.Take(PageSize)
.Future();
// var result = query.ToList();
var rowcount = session.QueryOver()
.Select(Projections.Count(Projections.Id()))
.FutureValue().Value;
var result = query.ToList();
int iRowCount = rowcount.Value();
Once you execute the .ToList() - It will hit the database. So you'd have to hit the database again to get the rowCount...Which defeats the purpose of Future<>. Do your ToList() AFTER you've done all your .Future<> queries.