how to get the total count of rows
from my previous question: multiple results in a single call
how would I get the count of all articles in a given categ开发者_运维技巧ory?
I prefer criteria query if possible (would love it if you could show me how to do it in both criteria and hql)
You'll have to use projections.
I believe, you'll have to create a criteria which will look something like this:
ICriteria crit = mySession.CreateCriteria (typeof(Article));
crit.Add (Restrictions.Eq ("Category", someCategory));
crit.SetProjection (Projections.Count("somePropertyNameOfArticle"));
int result = crit.UniqueResult<int>();
精彩评论