nHibernate: limit the result set of a mapped collection

Posted by HeavyWave on Stack Overflow See other posts from Stack Overflow or by HeavyWave
Published on 2010-03-07T11:02:25Z Indexed on 2010/03/25 2:53 UTC
Read the original article Hit count: 295

Filed under:

How do you limit the result set of a mapped collection in nHibernate? For instance:

Model.Items;

will always return all the Items for the given Model. Is there any way to force it to return only, say, 20 Items without creating a specific query ? Something like

Model.Items.SetMaxResults(20);

In other words, I would like nHibernate to return IQueryable instead of a simple IList, when I access a collection.

© Stack Overflow or respective owner

Related posts about nhibernate