Using named queries in the data access layer

Named queries encapsulated in query objects are a powerful combination. In this recipe, we will show you how to use named queries with your data access layer.

Getting ready

To complete this recipe, you will need the common service locator from Microsoft patterns and practices. The documentation and source code can be found at http://commonservicelocator.codeplex.com.

Complete the previous recipe: Setting up an NHibernate repository.

Following Fast testing with SQLite in-memory database recipe in Chapter 6, Testing, create a new NHibernate test project named Eg.Core.Data.Impl.Test.

Include the Eg.Core.Data.Impl assembly as an additional mapping assembly in your test project's App.Config with the following ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.