-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
NHibernate 4.x Cookbook - Second Edition
By :
We need to run several queries to display forms and web pages. For example, it's common to display search results one page at a time. This typically requires two queries. The first counts all the available results and the second fetches the data for only 10 or 20 results. MultiCriteria allows us to combine these two queries into a single database round trip, potentially speeding up our application. In this recipe, we'll show you how to use MultiCriteria to fetch a paged-result set of products.
Complete the Getting Ready instructions at the beginning of Chapter 4, Queries.
Add a new folder named MultiCriteria to the QueryRecipes project.
Add a new struct named PageOf to the folder:
public struct PageOf<T>
{
public int PageCount;
public int PageNumber;
public IEnumerable<T> PageOfResults;
}Add a new class named Queries to the folder:
using System; using System.Collections.Generic; using System.Linq; using...