我需要改變連接到使用NHibernate到左外連接的LINQ中。 我的代碼看起來象NHibernate左連接LINQ
IQueryable<DimServicePoint> spq =
from sp in session.Query<DimServicePoint>()
join spm in session.Query<DimServicepointMeter>() on sp.ServicePointKey equals spm.ServicePointKey into gj
from subsp in gj.DefaultIfEmpty()
where (sp.ServicePointID == servicePointID && sp.DimAccount.AccountKey != 0 && sp.StartDayID <= currentDateId && sp.EndDayID >= currentDateId)
select sp;
現在,我的要求是加入DimServicepointMeter左加入此查詢。 等效SQL查詢:
select * from dw.dim_servicepoint sp
left join dw.dim_servicepoint_meter spm on sp.servicepointkey = spm.servicepointkey
where sp.servicepointid = @ServicePointID and sp.accountkey != 0
and sp.startdayid <= @currentDateId and sp.enddayid >= @currentDateId
我沒有太多工作在NHibenate或LINQ所以沒有太多的想法怎麼辦左加入NHibernate的或LINQ。 任何幫助表示讚賞
http://stackoverflow.com/a/15590126/1162077 –