Chapter 7. The Data Access Layer

WHAT'S IN THIS CHAPTER?

  • Two data access strategies to help organize your persistence layer: Repository and Data Access Objects

  • Data patterns and principles to help you fulfill your data access requirement needs elegantly, including Lazy Loading, Identity Map, Unit of Work, and Query Object

  • An introduction to object relational mappers and the problems they solve

  • An enterprise domain-driven exercise with POCO business entities utilizing both NHibernate and the MS Entity Framework

So far, you have read about the business layer of an enterprise ASP.NET application, the patterns used to organize it, and the patterns found within. You then looked at the service layer, which gave an entry point into a system. This chapter focuses on the data access layer (DAL) and covers patterns that allow you to retrieve and persist your business entities, ensuring you leave your data in a valid state.

DESCRIBING THE DAL

The DAL is the layer in your application that is solely responsible for talking to the data store and persisting and retrieving your business objects. (Note the reference to a data store and not a database. You don't always have to have a database; sometimes an XML file is sufficient.) The DAL typically includes all the create, read, update, and delete (CRUD) methods, transaction management, data concurrency, as well as a querying mechanism to enable your business logic layer to retrieve objects for any given criteria.

The DAL should not contain business logic ...

Get Professional ASP.NET Design Patterns 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.