O'Reilly logo

NHibernate 4.x Cookbook - Second Edition by Jason Dentler, Alexander Zaytsev, Gunnar Liljas

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using QueryOver projections and aggregates

In some cases, we only need specific properties of an entity. In other cases, we may need the results of an aggregate function, such as average or count. In this recipe, we'll show you how to write QueryOver queries with projections and aggregates.

Getting ready

Complete the Getting Ready instructions at the beginning of this chapter.

How to do it…

  1. Add a new folder named QueryOverProjections to the project.
  2. Add a new class named QueryOverAggregateQueries to the folder, having the following code:
    using System; using System.Collections.Generic; using System.Linq; using NH4CookbookHelpers.Queries; using NH4CookbookHelpers.Queries.Model; using NHibernate; using NHibernate.Criterion; namespace QueryRecipes.QueryOverProjections ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required