user656822
user656822

Reputation: 1167

Nhibernate query over with multiple fetch and multiple conditions

How can I get same result with NHibernate QueryOver when using entity framework linq like this.

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

Upvotes: 2

Views: 1694

Answers (1)

Radim Köhler
Radim Köhler

Reputation: 123861

A syntax with QueryOver could look like this:

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

Sources:

Upvotes: 3

Related Questions