关于Linq to sql 怎么实现多表查询?
yoyo_ 2010-11-18 12:21:26 本人初学,这个多表查询让我纠结了,各位高手帮帮忙吧,谢谢啦!
如下:
这是SQL
select a.s910_01,a.s910_02,a.jobid,f.shift_B,f.shift_E,
case when s1.sums1 is null then 0 else s1.sums1 end as sums1
from BranchSchedule b inner join ats910 a on b.s910_01=a.s910_01
inner join contactdept c on a.deptid=c.id
inner join BranchShift f on b.s_shift=f.shift
left join (select empid,count(*) as sums1 from PTreservation
where
pos='502' and starttime between '201010' and '201011'
group by empid
) s1 on a.s910_01=s1.empid
where c.deptname like '%運動部'
and a.s910_36 is NULL and b.s_shift<>'@' and b.s210_01='502'
AND f.s210_01 = '502' and b.s_validity='201011' and
f.validity=(select max(f.validity) from BranchShift f
where f.shift=b.s_shift and f.s210_01='502') and b.s_day='18'
union (select a.s910_01,a.s910_02,a.jobid,s.on_time,s.off_time,
case when s1.sums1 is null then 0 else s1.sums1 end as sums1
from PTempshift s inner join ats910 a on a.s910_01 = s.empid
left join (select empid,count(*) as sums1 from PTreservation
where
pos='502' and starttime between '201010' and '201011'
group by empid
) s1 on a.s910_01=s1.empid
where s.pos = '502'
and s.shift_date =null)
order by a.jobid
现在要用LinQ来实现的话改怎么弄呢?