Nhibernate查询多个获取和多个条件

时间:2014-02-24 00:36:29

标签: c# .net nhibernate

在使用像这样的实体框架QueryOver时,如何使用NHibernate linq获得相同的结果。

var result = items
   .include("subEntity1")
   .include("subEntity2")
   .include("subEntity3")
   .where(...).skip(x).take(y); 

1 个答案:

答案 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>();

来源: