I am using NHibernate and Linq to NHibernate (mostly the same as Linq to SQL). What would I do to get the following:
I have class Garage, which has lots of Cars in it. I want to search Cars by year of manufacture, and also return the garage each car is in.
To get the cars, I do something like:
from item in session.Query<Car>()
where item.year == 2011
select item
The car class does not have garageID, the garage just has a collection of cars.
It’s called eager loading, check out this article http://mikehadlow.blogspot.com/2010/08/nhibernate-linq-eager-fetching.html