Linq-to-NHibernate 是否支持在单个查询中从多个实体中检索数据?
例如:
Dim query = From f In context.Session.Linq(Of Floor)() _
Select f.Id, f.Name, f.Building.Id, f.Building.Name
Dim results = query.ToList()
Building
的父实体在哪里Floor
。
Linq-to-NHibernate 是否支持在单个查询中从多个实体中检索数据?
例如:
Dim query = From f In context.Session.Linq(Of Floor)() _
Select f.Id, f.Name, f.Building.Id, f.Building.Name
Dim results = query.ToList()
Building
的父实体在哪里Floor
。
您将需要在 session.Linq 上使用 Expand 方法。例如(对不起,在 c# 中),
var linq = session.Linq<Floor>();
linq.Expand("Building"); //causes "Building" to be eagerly loaded.
//Then your linq query goes here...
I've been playing with Expand. Interesting point about the Repository pattern too.
The thing that immediately hit me though was the smell of the magic string "Building" in @Simon's example. I did eventually come across this blog post from Marcin Budny.
http://marcinbudny.blogspot.com/2009/10/typed-expand-for-linq-to-nhiberante.html
Works well for me.
这应该是可能的,因为 NHibernate 本身就支持这一点。但是我没有使用 Linq-to-NHibernate 的经验。
您是否尝试过查询,如果是,响应是什么?