【发布时间】:2010-11-24 23:04:39
【问题描述】:
选择具有子集合的父实体(不同)列表的最佳/首选方法是什么,该子集合包含子参数列表中所有条目的匹配项?
我正在执行我的搜索的“任何”版本,如下所示:
select p.Id, p.Name from parent p
where exists(from p.Children c where c in (:childList))
但是,我对如何最好地执行此搜索的“全部”版本感到有些困惑。目前,我正在为我感兴趣的每个孩子动态创建 hql;像这样:
select p.Id, p.Name from parent p
where :child1 in elements(p.Children)
and :child2 in elements(p.Children)
-- etc...
我不禁想到有更好的方法来做到这一点;谁能指出我正确的方向?
作为参考,我使用的是 NHibernate 2.1.2
【问题讨论】:
-
这看起来基本上像关系除法,但使用参数而不是表格。见simple-talk.com/sql/t-sql-programming/…
-
@Mauricio:很有趣,我以前没听说过这个术语,谢谢你的参考。
标签: nhibernate hibernate hql