Chapter 4. Queries

In this chapter, we will cover the following recipes:

  • Query entities by ID
  • Using LINQ to NHibernate
  • Using CriteriaQueries
  • Using QueryOver
  • Using QueryOver projections and aggregates
  • Using the Hibernate Query Language
  • Using native SQL
  • Eager loading with LINQ
  • Eager loading with Criteria
  • Eager loading with QueryOver
  • Eager loading with HQL
  • Eager loading with SQL
  • Using named queries
  • Using detached queries
  • Using HQL for bulk data changes
  • Filtering collections
  • Using result transformers
  • Extra lazy collections

Introduction

Since all the recipes in this chapter deal with querying, we have provided the necessary setup and data using the NH4CookbookHelpers library. You can easily adapt the recipes to your own liking, but if you want to only test the queries, ...

Get NHibernate 4.x Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.