In this chapter, we will cover the following topics:
Setting up session-per-web request
Setting up session-per-presenter
Creating a session ASP.NET MVC action filter
Creating a transaction ASP.NET MVC action filter
Save entities to the database
Using session.Merge
Using session.Refresh
Handle concurrency using session.Lock
Using dictionaries as entities
Using NHibernate with transaction scope
Introduction
NHibernate leaves session and transaction management up to the application. There are a number of different ways to manage sessions and transactions, and they depend greatly on the specific application architecture. In addition to a few interesting session methods, the recipes in this chapter show how to handle sessions and transactions for these different types of applications.