标签: nhibernate linq-to-sql
我正在使用NHibernate和Linq来NHibernate(大多数与Linq to SQL相同)。我该怎么做才能得到以下内容:
我有车库,里面有很多车。我想按制造年份搜索汽车,并返回每辆车所在的车库。
为了获得汽车,我做了类似的事情:
from item in session.Query<Car>() where item.year == 2011 select item
汽车类没有车库ID,车库只有一系列汽车。
答案 0 :(得分:1)
这称为急切加载,请查看此文章http://mikehadlow.blogspot.com/2010/08/nhibernate-linq-eager-fetching.html