Hi, I am trying to write a query using the criteria API that joins to an associated collection and generally speaking it works OK. But I want to do a left outer join and qualify the join with two conditions rather than have the one condition qualifying the join and one condition in the where clause.
e.g.
_session.CreateCriteria(typeof(IPlan))
.CreateCriteria("LinkedImpacts", "LI", JoinType.LeftOuterJoin)
.Add(Expression.IdEq(25))
.AddOrder(Order.Asc("LI.Id"))
.List<IPlan>();
generates something like:
select p.planid, p.name, i.impactid as linked
from rm_plan p left outer join rm_impact i
on i.planid = p.planid
where i.impactid = 25
order by linked
whereas I want:
select p.planid, p.name, i.impactid as linked
from rm_plan p left outer join rm_impact i
on i.planid = p.planid
and i.impactid = 25
order by linked
The latter is subtly different and gives me different results (which is what I want). Is there a way to achieve this using the criteria API?
Thanks in advance.
Julian Jelfs
|