O'Reilly logo

NHibernate 3.0 Cookbook by Jason Dentler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

In this recipe, we'll use a stateless session to update our movie prices.

Getting ready

Just as before, follow Configuring NHibernate with App.config from Chapter 2 to set up a console application with NHibernate and our Eg.Core model.

How to do it...

  1. To create some data with which to work, add the following code to your Main method:
    using (var session = sessionFactory.OpenStatelessSession()) { using (var tx = session.BeginTransaction()) { for (int i = 0; i < ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required