Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Learning NHibernate 4
  • Table Of Contents Toc
  • Feedback & Rating feedback
Learning NHibernate 4

Learning NHibernate 4

By : Suhas H Chatekar
3.6 (9)
close
close
Learning NHibernate 4

Learning NHibernate 4

3.6 (9)
By: Suhas H Chatekar

Overview of this book

This book targets .NET developers who have never used an ORM before, developers who have used an ORM before but are new to NHibernate, or have used NHibernate sparingly and want to learn more about NHibernate.
Table of Contents (13 chapters)
close
close
12
Index

Retrieving entities by identifiers


If you recall the unit tests that we wrote in the previous chapters, we commonly used a method named Get<T> on ISession to retrieve a persistent instance of an entity by its id. Following is relevant part of that code:

using (var transaction = session.BeginTransaction())
{
  var employee = session.Get<Employee>(id);
  transaction.Commit();
}

You might be wondering what the reason behind providing this method is. All we are doing is querying an entity by its primary key. Why not use criteria query, QueryOver, or LINQ to query entities by primary key? Well, you can use those methods when you are not querying by identifier, but if you are querying by identifier then Get<T> has some optimizations built in that make it a preferred choice over any other querying method. Even other querying methods will use Get<T> internally if they need to load an entity by identifier.

Get<T> will first check whether an entity is present in the identity...

Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Learning NHibernate 4
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist download Download options font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon