no, this code will return me count of specific category: select count(*) from products p inner join categories c on p.category_Id=c.Id where c.Id=1
but what i need is category list with extra column that calculate product count for each category On Tue, Aug 17, 2010 at 14:28, José F. Romaniello <[email protected]>wrote: > You started wrong. If you are going to count Products, you should start > with Products: > > CurrentSession.CreateCriteria<Product>() > .CreateAlias("Category", "cat") > .Add(Restrictions.Eq("cat.Id", 1)) > .SetProjection(Projections.RowCount()) > .UniqueResult<int>(); > > > I am not really sure about the last part. > > > 2010/8/17 Sasha <[email protected]> > > select name, >> (select count(*) from products where >> products.category_Id=categories.Id) as productCount >> from categories >> >> starting with: >> session.CreateCriteria<Category>() >> >> but whats next? >> >> -- >> You received this message because you are subscribed to the Google Groups >> "nhusers" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]<nhusers%[email protected]> >> . >> For more options, visit this group at >> http://groups.google.com/group/nhusers?hl=en. >> >> > -- > You received this message because you are subscribed to the Google Groups > "nhusers" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<nhusers%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. > -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
