开发者

NHibernate Eager Loading Collections + Paging

Here is an example of my entities that I am trying to return with eager loaded collections.

Mixes -> Tracks (collection) -> Tags (collection)

I need to return a paged list of Mixes with eager loaded tracks & tags, without paging it is relativly simple by开发者_开发知识库 using the Future<>() function to run multiple queries for the tracks + tags.

Because this data needs to be paged...how can I get all my data back so that NHibernate won't get the N+1 issue when displaying my data.

Paul


  1. Fetch the Mixes page you want, without any Tracks or Tags.
  2. Fetch all the Tracks (left join Tags) that correspond to the all the Mixes you fetched in the step above (i.e. if you're using HQL, use SetParameterList to pass all the Mixes IDs)

Total: 2 queries.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜