select name,
(select count(*) from products where products.category_Id=categories.Id) as productCount
from categories
session.CreateCriteria<Category>()
但接下来呢?
我甚至不知道如何在Google上搜索它?
答案 0 :(得分:1)
想想你的查询
SELECT categories.Id, count(categories.Id)
FROM categories inner join products on products.category_Id=categories.Id
group by categories.Id
我认为他们会产生相同的结果。
搜索谷歌
nhibernate criteria join
和
CreateAlias