QueryOver
NHibernateの新しい API を使用して、次のようなことを行う必要があります。
select c.*
from Category c
where not exists (
select *
from CategoryProduct cp
where cp.CategoryID = c.Id
and cp.ProductID = 'DogFood'
)
つまり、「ドッグフードを含まないすべてのカテゴリを教えてください」です。
私の最初の考えは次のようなものでした:
IEnumerable<Category> FindCategoriesWithoutProduct(Product product)
{
return _session
.QueryOver<Category>()
.Where(c => c.Products.Contains(product))
.List();
}
ただし、これによりNHibernate.Impl.ExpressionProcessor
、「認識されないメソッド呼び出し」が発生して爆発しSystem.Collections.Generic.ICollection<T>.Contains()
ます。
これを行うには、おそらくICriterion
.