我需要改变连接到使用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 –