I’m trying to use NHibernate filters but I’m obtaining a really weird SQL translation
In the mapping file I have this fragment:
<filter name="onlyMProv"
condition="Abbreviation in (SELECT AllowedAbbreviation from dbo.AllowedDistricts)" />
in the code then I wrote
session.EnableFilter("onlyMProv");
var districts = session.CreateQuery("from District");
but nHibernate translate this into
select [fields...]
from dbo.Districts district0_ where district0_.Abbreviation in
(SELECT district0_.AllowedAbbreviation from dbo.AllowedDistricts)
Which returns, a “Column name AllowedAbbreviation is not valid”.
As you can see it put the alias district0_ in the subquery…
Any idea ? Am I doing something wrong ?
Thanks in advance!
all columns without prefix are treated as columns of the owning entity. simple solution: