2
select name,
(select count(*) from products where products.category_Id=categories.Id) as productCount
from categories
session.CreateCriteria<Category>()
但是接下來呢?我如何在NHibernate中執行此查詢以獲取子女人數
我甚至不知道如何在Google中搜索它?
我認爲這應該是更好的解決方案,然後內部聯接,任何方式,應該離開加入,因爲我不想錯過類別噸他們沒有任何產品 – Sasha 2010-08-17 08:52:31
你對兩者都是對的。我重寫你的查詢的唯一原因是因爲它會更容易翻譯成nhibernate那種方式。 – 2010-08-17 09:03:03