Using QueryOver

NHibernate 3.0 added a new fluent syntax to criteria queries. Although it's not an actual LINQ provider, it does bring the familiar lambda syntax to criteria queries, eliminating the magic strings problem. In this recipe, we'll show you the QueryOver syntax for the criteria queries from our last recipe.

Getting ready

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

How to do it…

  1. Add a new folder named QueryByQueryOver to the project.
  2. Add a new class named QueryOverQueries to the folder:
    using System.Collections.Generic; using NH4CookbookHelpers.Queries; using NH4CookbookHelpers.Queries.Model; using NHibernate; namespace QueryRecipes.QueryByQueryOver { public class QueryOverQueries : IQueries { private readonly ...

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.