在 nhibernate 中,我有两个与多对一映射关联的类:
<class name="Employee" table="Employee">
..
<bag name="orgUnits">
<key column="id" />
<one-to-many name="OrgUnit" class="OrgUnit">
</bag>
..
</class>
我想使用标准表达式来仅获取集合为空(即没有组织)的员工,如下所示:
IList employeesWithNoOrgUnit = sess.CreateCriteria(typeof(Employee))
.Add( Expression.IsNull("OrgUnits") )
.List();
这不会像我预期的那样过滤集合。