We've learned to use MultiCriteria and MultiQuery to batch our queries together. NHibernate's Futures feature provides a simpler API for batching criteria and queries. In this recipe, I'll show you how to use NHibernate's new Futures feature to return a paged product result.
CountAllProducts.hbm.xmlwith the following xml code. Don't forget to set the Build action to Embedded Resource.
<?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> <query name="CountAllProducts"> <![CDATA[ select count(p.Id) from Product p ]]> </query> ...