Chapter 7. Data Access Layer

In this chapter, we will cover the following topics:

  • Transaction auto-wrapping for the data access layer
  • Setting up an NHibernate repository
  • Using named queries in the data access layer
  • Using ICriteria in the data access layer
  • Using paged queries in the data access layer
  • Using LINQ specifications in the data access layer

Introduction

There are two types of data access layers that are common in today's applications: Repositories and Data Access Objects (DAO). In reality, the distinction between these two has become quite blurred; however, in theory, it's as follows:

  • A repository should act like an in-memory collection. Entities are added to and removed from the collection and its contents can be enumerated. Queries are typically handled by sending query specifications to the repository.
  • A DAO is simply an abstraction of an application's data access. Its purpose is to hide the implementation details of the database access from the consuming code.

The first recipe shows the beginning of a typical data access object. The remaining recipes show how to set up a repository-based data access layer with NHibernate's various APIs.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.208.12