请各个大神帮我瞅瞅这段SQL怎么写成LINQ
小弟初学LINQ,~
所以不知道怎么写~奉上SQL代码
select a.ClassName ,sum(case when b.Gender = '1' then 1 else 0 end) man,
sum(case when b.Gender = '0' then 1 else 0 end) woman
from class_semester_ships a , student b ,semester c,classtb e,org f
where e.PKClassID=a.FKClassID and c.PKSemesterID=a.FKSemesterID and b.FKClassID=e.PKClassID
and c.SemesterName='2013年上学期' and f.PKOrgID= e.FKOrgID
GROUP by a.ClassName
大神们~麻烦指导下小弟 谢谢了~分不多~ 还望别介意
------解决方案--------------------本帖最后由 q107770540 于 2013-07-08 09:57:02 编辑
var query=from a in db.class_semester_ships
from b in db.student
from c in db.semester
from e in db.classtb
from f in db.org
where e.PKClassID==a.FKClassID && c.PKSemesterID==a.FKSemesterID && b.FKClassID==e.PKClassID
&& c.SemesterName=="2013年上学期" && f.PKOrgID == e.FKOrgID
group new {a,b} by a.ClassName into g
select new
{
ClassName=g.Key,
man=g.Where(x=>x.b.Gender==1).Sum(x=>x.b.Gender),
woman=g.Where(x=>x.b.Gender==0).Sum(x=>x.b.Gender+1),
};