Using stateless sessions
When processing large amounts of data, you can usually improve performance by using an API that's closer to the bare metal, often times trading off some higher-level features in the process. In NHibernate, this high performance, low-level API is the stateless session.
Here we'll use a stateless session to update our movie prices.
Getting ready
Complete the Getting Ready instructions at the beginning of Chapter 4, Queries.
How to do it...
Add a new folder named
Stateless
to theQueryRecipes
project.Create a class named
Recipe
in the folder:using NH4CookbookHelpers.Queries; using NH4CookbookHelpers.Queries.Model; using NHibernate; using NHibernate.Linq; using System; using System.Linq; namespace QueryRecipes.Stateless { public class Recipe : QueryRecipe { } }
To create some data with which to work, add the following method to your
Recipe
class:protected override void AddData(ISessionFactory sessionFactory) { using (var session = sessionFactory.OpenStatelessSession...