我使用 Fluent NHibernate 连接了一个商店和员工类,其中商店可以有许多员工,如下所示:
public class Store
{
public virtual IList<Employee> Employees { get; set; }
//other store properties
}
public class Employee
{
public virtual Store Store { get; set; }
public virtual bool? SomeStatus1 { get; set; }
}
我需要让所有拥有未将 SomeStatus1 设置为 true 的员工的商店。
我在这里的可行尝试失败了:
Session.CreateCriteria(typeof(Store))
.Add(Restrictions.Not(Restrictions.Eq("Employees.SomeStatus1", true))
.List<Store>();
知道我该怎么做吗?
我的尝试失败的原因是因为员工列表没有 SomeStatus1 的属性......这很明显。
我不知道的是,如何让 NHibernate 只获得在我正在寻找的州拥有员工的商店......
我想我想问 NHibernate 是加入...但我不知道如何要求它这样做...