开发者

NHibernate - Limiting results from eagerly fetched collections

I've been taking a look at the NHProf Nhibernate profiler (Really great tool, but unfortunately priced a bit too highly in my opinion). And it is raises a warning that there is an 'unbounded result set' (the child collection)for my queries of this type (eagerly fetched child collections):

ICriteria criteria = session.CreateCriteria<SomeType>()
                .SetFetchMode("ChildCollection", FetchMode.Eager)
                .Add(Restrictions.IdEq(id));

My question is, how should I be handling this type of query? Is there a way to limit the eagerly fetched results somehow?

The other problem I suppose is that with a limited collection, how to access f开发者_运维问答urther results when needed? (I mean I guess there is no lazy loaded after you have populated it). Please tell me if I'm not explaining myself clearly!

Thanks.


You can page over the collection but if you know that collection isn't going to be huge then I'd just ignore that alert. There is also the batch-size collection mapping parameter.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜