So far, we've covered various queries using LINQ, the Criteria API and its sibling, the QueryOver
syntax. NHibernate provides another, more powerful, query method named Hibernate Query Language, which is a domain-specific language that blends familiar SQL-like syntax with Object-Oriented thinking. In this recipe, we'll show you how to use the Hibernate Query Language to perform the same queries as in the previous recipes.
Add a new folder named
QueryByHql
to the project.Add a new class named
HqlQueries
to the folder:using System.Collections.Generic; using NH4CookbookHelpers.Queries; using NH4CookbookHelpers.Queries.Model; using NHibernate; namespace QueryRecipes.QueryByHql { public class HqlQueries : IQueries, IAggregateQueries { private readonly ISession _session; public HqlQueries(ISession session) { _session = session; } public...