-
Book Overview & Buying
-
Table Of Contents
NHibernate 4.x Cookbook - Second Edition
By :
Similar to how we can combine several ICriteria and QueryOver queries into a single database round trip with MultiCriteria, we can combine several HQL and/or SQL queries with MultiQuery. Particularly in a production setting, where the database and application are on separate machines, each round trip to the database is very expensive. Combining work in this way can greatly improve application performance. In this recipe, we'll show you how to fetch a product count and page of product results using a MultiQuery.
Complete the Getting Ready instructions at the beginning of Chapter 4, Queries.
Add a new folder named MultiQueries 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...