I am attempting to execute the following NH query:
Code:
session.CreateCriteria<Derived>()
.SetProjection(
Projections.SqlProjection(
"case when {alias}.Name between 'A' and 'N' then 'A-M' else 'Other' end as range",
new[] { "range" },
new[] { NHibernateUtil.String }))
.List();
My Derived class is mapped as a <joined-subclass> of Base. The {alias}.Name property is implemented in the Base class. This generates the following incorrect SQL:
Code:
SELECT
case
when this_.Name between 'A' and 'N' then 'A-M'
else 'Other'
end as range
FROM Derived this_
inner join Base this_1_ on this_.BaseFK=this_1_.PK
Note that
this_.Name should actually be
this_1_.Name. Is this a bug, or am I doing something wrong?
-- Brian