NHibernate 4.x Cookbook - Second Edition by Liljas Gunnar & Zaytsev Alexander & Dentler Jason
Author:Liljas, Gunnar & Zaytsev, Alexander & Dentler, Jason [Liljas, Gunnar]
Language: eng
Format: azw3
Publisher: Packt Publishing
Published: 2017-01-30T16:00:00+00:00
Run the application and start the QueryBySql recipe.
How it works…
We won't get into the details of the SQL queries.
Eager loading with LINQ
Often, when we query for some set of entities, we also want to load some of the related entities. In this recipe, we'll show you how we can use LINQ extensions to eager load the child collections of our query results.
Getting ready
Complete the Getting Ready section at the beginning of this chapter.
How to do it…
Create a new folder named EagerLoadingWithLinq in the project.
Add a new class named Recipe to the folder:using System.Linq; using NH4CookbookHelpers.Queries; using NH4CookbookHelpers.Queries.Model; using NHibernate; using NHibernate.Linq; namespace QueryRecipes.EagerLoadingWithLinq { public class Recipe : QueryRecipe { protected override void Run(ISession session) { var book = session.Query<Book>() .Fetch(x => x.Publisher) .FirstOrDefault(); Show("Book:", book); var movies = session.Query<Movie>() .FetchMany(x => x.Actors) .ToList(); Show("Movies:", movies); } } }
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
The Mikado Method by Ola Ellnestam Daniel Brolund(23685)
Hello! Python by Anthony Briggs(22818)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(21647)
Kotlin in Action by Dmitry Jemerov(20688)
Dependency Injection in .NET by Mark Seemann(20586)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(20497)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(19601)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(18401)
Grails in Action by Glen Smith Peter Ledbrook(17522)
Adobe Camera Raw For Digital Photographers Only by Rob Sheppard(16984)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(14939)
Secrets of the JavaScript Ninja by John Resig & Bear Bibeault(12894)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(11278)
A Developer's Guide to Building Resilient Cloud Applications with Azure by Hamida Rebai Trabelsi(10604)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(10539)
Hit Refresh by Satya Nadella(9141)
The Kubernetes Operator Framework Book by Michael Dame(8546)
Exploring Deepfakes by Bryan Lyon and Matt Tora(8374)
Robo-Advisor with Python by Aki Ranin(8322)