Is it possible to implement left join in linq in NHibernate 3.2 ?
I want to achive a linq query similar to this sql query:
select v.*, cp.EffectiveStart
from Visits v
join VisitServices vs on v.Id = vs.VisitId
left join CarePlans cp on cp.Id = vs.CarePlanId
I have written such linq query:
var c = (from v in EntitiesRepository
join vs in _visitServiceRepository on v.Id equals vs.Visit.Id
join cp in _carePlanRepository on vs.CarePlan.Id equals cp.Id into pp
from pl in pp.DefaultIfEmpty()
select new { Visit = v, EffectiveStart = pl.EffectiveStart}).ToList();
But I got this exception
The method or operation is not implemented.
Answer: I was able to fix the issue using navigation property:
var c = (from v in EntitiesRepository
join vs in _visitServiceRepository on v.Id equals vs.Visit.Id
select new { Visit = v, EffectiveStart = vs.CarePlan == null ? null : (DateTime?)vs.CarePlan.EffectiveStart}).ToList();