Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
NHibernate 4.x Cookbook

You're reading from   NHibernate 4.x Cookbook Over 90 incredible and powerful recipes to help you efficiently use NHibernate in your application

Arrow left icon
Product type Paperback
Published in Jan 2017
Publisher Packt
ISBN-13 9781784396428
Length 448 pages
Edition 2nd Edition
Arrow right icon
Authors (4):
Arrow left icon
 Liljas Liljas
Author Profile Icon Liljas
Liljas
Darshan Joshi Darshan Joshi
Author Profile Icon Darshan Joshi
Darshan Joshi
 Zaytsev Zaytsev
Author Profile Icon Zaytsev
Zaytsev
Jason Dentler Jason Dentler
Author Profile Icon Jason Dentler
Jason Dentler
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

NHibernate 4.x Cookbook Second Edition
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
1. The Configuration and Schema FREE CHAPTER 2. Models and Mappings 3. Sessions and Transactions 4. Queries 5. Improving Performance 6. Testing 7. Data Access Layer 8. Extending NHibernate 9. NHibernate Contribution Projects Index

Handle concurrency using session.Lock


It's often important to handle scenarios where two or more clients may try to work with the same entities, concurrently. In Chapter 2, Models and Mappings, in section: Handling versioning and concurrency we discussed how to handle that using versioning and optimistic concurrency. A more aggressive approach is to use pessimistic concurrency, where specific rows in the database are explicitly locked for certain operations. Many DBMSes, such as SQL Server, has a good support for this and in this recipe we'll show how NHibernate can use that functionality.

Getting ready

Follow the Getting ready step in the Save entities to the database recipe in this chapter.

How to do it…

Since this recipe requires specific database support, you can't run it using the SQLite database, which is the default in NH4CookbookHelpers. Reconfigure the recipe runner by setting the RecipeLoader.DefaultConfiguration property or simply override the Configure method in the Recipe class...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £13.99/month. Cancel anytime
Visually different images