O'Reilly logo

Learning NHibernate 4 by Suhas Chatekar

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

Unit of work

You might argue that we do not need unit of work in the previous situation as we are only saving a single entity using one call to ISession.Save. But remember that saving an employee instance results in multiple database records being inserted, and ideally, the whole operation of inserting these multiple records in database should be an atomic operation. Unit of work guarantees the atomicity we need. Before we bring a notion of unit of work, I would like to spend some time talking about scope of unit of work in this particular situation. A unit of work has to begin somewhere and end somewhere. Determining where unit of work begins and ends is crucial to robustness of data access layer.

Scope of unit of work for web applications

Web ...

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