NHibernate.Linq to Criteria API translation help needed

Posted by Arnis L. on Stack Overflow See other posts from Stack Overflow or by Arnis L.
Published on 2010-03-14T21:18:01Z Indexed on 2010/03/14 21:25 UTC
Read the original article Hit count: 359

Filed under:

I'm not sure how to add paging to this:

Session.Linq<Article>()
  .Where(art => art.Tags.Any(t => t.Name == tag)).ToList().

So i decided to use Criteria API.

var rowCount = Session.CreateCriteria(typeof(Article))
  .SetProjection(Projections.RowCount()).FutureValue<Int32>();

var res = Session.CreateCriteria(typeof(Article))
  .Add(/* any help with this? :) */)
  .SetFirstResult(page * pageSize)
  .SetMaxResults(pageSize)    
  .AddOrder(new Order("DatePublish", true))
  .Future<Article>();

totalCount = rowCount.Value;

Any help appreciated.

© Stack Overflow or respective owner

Related posts about nhibernate