用孩子的一个子集过滤收集孩子 [英] Filter child collection using a child collection of the child

查看:112
本文介绍了用孩子的一个子集过滤收集孩子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

犯错,我想不出更好的称号。基本上我有一类叫做MarketGroups,这有有MarketTypes集合的子集Markgroups和MarketTypes有元组的集合。

Err, I can't think of better title. Basically I have a class called MarketGroups, this has a child collection Markgroups that has a collection of MarketTypes and MarketTypes has a collection of MetaGroups.

我希望能够,在一个查询,加载家长,只返回有它的元组集合在一个特定的元组MarketTypes儿童MarketGroups

I would like to be able to, in one query, load the Parent, and only return Child MarketGroups that have MarketTypes with one specific MetaGroup in its MetaGroup collection.

我知道这个问题:<一HREF =http://stackoverflow.com/questions/247571/filter-child-collection-returned-with-aggregate-root-using-nhibernate> http://stackoverflow.com/questions/247571/filter-child-集合返回-与聚集型根使用,NHibernate的但不可以我在寻找的解决方案,我想这样做在代码中最好的一个查询,但我不会。介意分裂它

I am aware of this question: http://stackoverflow.com/questions/247571/filter-child-collection-returned-with-aggregate-root-using-nhibernate but is not the solution I'm looking for, I want to do this in code ideally as one query, but I wouldn't mind splitting it.

:)

推荐答案

除非你限制默认情况下加载(使用您链接到的方法),你必须加载父在一个查询,而在另一个孩子的孩子们。
AFAIK有没有办法查询对象并有只加载某些儿童。

Unless you restrict the children that are loaded by default (using the method you linked to) you'll have to load the Parent in one query and the children in another. AFAIK there's no way to query an object and have only certain children loaded.

您总是可以使用MultiQuery在同一时间头脑提交他们你。

You could always use MultiQuery to submit them at the same time mind you.

HQL类似(这可能会丢失标志位):

HQL something like (this may be missing the mark a bit):

            select
                mt
            from 
                MarketGroup mg
            inner join
                mg.MarketTypes mt
            inner join
                mt.MetaGroups mg
            where 
               mg.ID=12312 and mg.ID=3214123

这篇关于用孩子的一个子集过滤收集孩子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆