NHibernate筛选器SQL转换

NHibernate筛选器SQL转换,nhibernate,Nhibernate,我试图使用NHibernate过滤器,但我得到了一个非常奇怪的SQL翻译 在映射文件中,我有以下片段: <filter name="onlyMProv" condition="Abbreviation in (SELECT AllowedAbbreviation from dbo.AllowedDistricts)" /> 但nHibernate将此转化为 select [fields...] from dbo.Districts district0_ where dist

我试图使用NHibernate过滤器,但我得到了一个非常奇怪的SQL翻译 在映射文件中,我有以下片段:

<filter name="onlyMProv" 
  condition="Abbreviation in (SELECT AllowedAbbreviation from dbo.AllowedDistricts)" />
但nHibernate将此转化为

select [fields...] 
from dbo.Districts district0_ where district0_.Abbreviation in 
    (SELECT district0_.AllowedAbbreviation from dbo.AllowedDistricts)
返回时,允许的列名缩写无效

如您所见,将别名district0_uu放入子查询中。。。 有什么想法吗?我做错什么了吗


提前谢谢

所有不带前缀的列都被视为所属实体的列。简单解决方案:

condition="Abbreviation in (SELECT ad.AllowedAbbreviation from dbo.AllowedDistricts ad)"

您好,firo,谢谢您的帮助,事实上您的建议在演示的案例中非常有效,但是现在如果我在表函数调用中使用子查询,即SELECT ad中的CONDICTION=缩写。dbo中的ALLOWED缩写。MyFunc1 ad将翻译为[…]如果SELECT ad.ALLOWED dbo.MyFunc1 district0_U2;.ad[…]中的district0_U2;.缩写,导致sqlserver尖叫它不知道ad。还有其他宝贵的建议吗?嗯,可能是dbo.MyFunc1 ad或dbo.MyFunc1 ad
condition="Abbreviation in (SELECT ad.AllowedAbbreviation from dbo.AllowedDistricts ad)"