NHibernate:用于检索具有空计数子集合的所有实体的条件表达式
在nhibernate中,我有两个类与多对一映射相关:NHibernate:用于检索具有空计数子集合的所有实体的条件表达式,nhibernate,criteria,Nhibernate,Criteria,在nhibernate中,我有两个类与多对一映射相关: <class name="Employee" table="Employee"> .. <bag name="orgUnits"> <key column="id" /> <one-to-many name="OrgUnit" class="OrgUnit"> </bag> .. </class> 这并没有像我期望的那样过滤集合。同事刚
<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( Restrictions.IsEmpty("OrgUnits") )
.List();
这是收藏吗?如果是这样的话,从员工的角度看,这不应该是一对多的关系吗?
IList employeesWithNoOrgUnit = sess.CreateCriteria(typeof(Employee))
.Add( Restrictions.IsEmpty("OrgUnits") )
.List();