Thursday, January 3, 2013

NHiberbnate fix added ability to use ToFutureValue with aggregating queries

The new NHibernate Linq Provider patch from Alexander I. Zaytsev added ability to use ToFutureValue with aggregating queries. Here follows the example:

var futurePerson = session.Query<Person>()
.Where(x => x.Id == personId)
.ToFutureValue(x => x.Count()); 
This feature is very useful with pagination for example:
var query = session.Query<Person>();
var countQuery = query.ToFutureValue(x => x.Count());
var page = query.Skip(pageIndex * pageSize).Take(pageSize).ToFuture();
NHibernate release version: 3.3.3.GA.
JIRA issue: NH-3184
Github pull request: #120

Kudos to Alexander I. Zaytsev!