NHibernate连接过滤器(With子句?) [英] NHibernate Join Filter (With clause?)

查看:84
本文介绍了NHibernate连接过滤器(With子句?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到一种使用HQL在联接对象上执行过滤器"的方法.例子:

I am trying to figure out a way with HQL to do a "filter" on the joined object. Exmaple:

from Cat as cat
    inner join tableX as x
    left join tableY as y
        with x.someID = y.someID

我知道" with "子句可与参数:param一起使用,如下所示:

I know that the "with" clause works fine with parameters :param like this:

from Cat as cat
    inner join tableX as x
    left join tableY as y
        with x.someID = :param

但是对于我而言,我没有参数.

But in my case I do not have a parameter.

这里有更多信息:

Table Cat       TableX:              TableY:
---------       ------               --------
PK ID           PK EntityID          PK EntityID
Column 1        Column State         Column State     
Column 2        Column 1             Column 1
Column 3        Column 2

表Cat和表Y具有一对一映射. Table Cat和Table X具有一对多映射.

Table Cat and Table Y are with one-to-one mapping. Table Cat and Table X are with one-to-many mapping.

我基本上想在HQL中说:

I basically want to say in HQL:

SQL:    SELECT *
        FROM Cat c
        INNER JOIN TableX x on c.ID = x.EntityID
        LEFT JOIN TableY y on x.EntityID = y.EntityID and x.State = y.State

对此有任何想法或解决方法吗?

Any ideas for this or ways around it?

提前谢谢!

推荐答案

我相信,如果没有映射关联,您想要实现的目标是不可能的.您不能进行外部theta联接,只能进行交叉和内部.

I believe what you want to achieve is not possible without a mapping association. You can't do an outer theta join, only cross and inner.

这篇关于NHibernate连接过滤器(With子句?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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