O'Reilly logo

NHibernate 4.x Cookbook - Second Edition by Jason Dentler, Alexander Zaytsev, Gunnar Liljas

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

Eager loading child collections

Often, when we query for some set of entities, we also need to load a few children of those entities. In the Eager loading with… recipe, in the previous chapter, we learned how to use different fetch syntaxes to eager load referenced entities and collection. We concluded that there are a few scenarios where the standard methods don't work as desired. In this recipe, we'll show you how to use subqueries and/or NHibernate's Futures, together with the session cache, to overcome these issues.

Getting ready

Complete the Getting Ready instructions at the beginning of Chapter 4, Queries.

How to do it...

  1. Add a new folder named AdvancedEagerLoading to the QueryRecipes project.
  2. Add a new class named Recipe to the folder:
    using ...

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