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 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.