在使用像这样的实体框架QueryOver
时,如何使用NHibernate linq
获得相同的结果。
var result = items
.include("subEntity1")
.include("subEntity2")
.include("subEntity3")
.where(...).skip(x).take(y);
答案 0 :(得分:3)
QueryOver
的语法可能如下所示:
var query = session.QueryOver<MyEntity>()
// force the collection inclusion
.Fetch(x => x.Collection1).Eager
.Fetch(x => x.Collection2).Eager
...
// force the relations inclusion
.Fetch(x => x.SubEntity1).Eager
.Fetch(x => x.SubEntity2).Eager
...
// paging
.Skip(x)
.Take(y);
var list = query
.List<MyEntity>();
来源: