Chapter 15. Data access with NHibernate

 

This chapter covers

  • Decoupling data access from the core and UI
  • Configuring NHibernate mappings
  • Bootstrapping NHibernate
  • Invoking data access from ASP.NET MVC

Even though the ASP.NET MVC Framework is focused on the presentation layer, many developers work on small applications that don’t need several layers of business logic and separation between the presentation layer and the data store. Some of these examples have only a small handful of simple screens that store and retrieve data in small databases. For these small applications, simple separation patterns may be appropriate, but many small applications grow much larger than originally anticipated. When this happens, separation of concerns is critical to the long-term maintainability of the software.

To achieve separation of concerns when communicating with a relational database, you can use an object-relational mapping (ORM) tool, such as the popular open source NHibernate project. You saw that with NuGet, you can use many libraries and frameworks that are written by developers around the world. NHibernate is one of the libraries available through NuGet. This library makes data access with relational databases trivial.

15.1. Functional overview of reference implementation

15.2. Application architecture overview

15.3. Exploring the Core

15.4. NHibernate configuration–infrastructure of the application

15.5. Presenting the model through the UI

15.6. Pulling it together

15.7. Summary