我正在尝试在 NHibernate 中为以下语句创建标准:
SELECT *
FROM InventoryItems
where id not in (select inventory_id from InventoryItemCategories where Category_Id = 'EB0DA6DE-DC18-4306-9EF7-E506463555A9')
或者我认为这个更好
SELECT *
FROM InventoryItems
where id not exists (select inventory_id from InventoryItemCategories where Category_Id = 'EB0DA6DE-DC18-4306-9EF7-E506463555A9')
我已经尝试过了,但它不起作用:
var criteria = Session.CreateCriteria<InventoryItem>()
.Add(Subqueries.WhereNotExists(("id"), DetachedCriteria.For<InventoryItemCategories>()
.Add(Restrictions.Eq("Category_id",inventoryCategoryId))));
非常感谢您的帮助