var query = default(IEnumerable<SchoolJoinCountItem>);
//获取学校的报名竞赛
var schoolsign = (from sign1 in db.JS_SchoolSign
select new { SchoolId = sign1.SchoolId, ProjectId = sign1.JS_Subject.ProjectId }).Union(
from sign2 in db.JS_StudentSign
select new { SchoolId = sign2.SchoolId,ProjectId = sign2.JS_Subject.ProjectId}
);
var projectList = FindProjectByOptions(nf,xq,jb,zl).Where(e => e.EditFlag == 2);
var data = from sp in projectList
from s in schoolsign
where sp.Id == s.ProjectId
select new
{
XXDM = s.SchoolId,
JSJB = sp.TypeId
};
//此处报错
query = from sc in db.JS_School
join sj in data on sc.Id equals sj.XXDM into p
select new SchoolJoinCountItem
{
XXDM = sc.Id,
XXMC = sc.Name,
QGJS = p.Where(e => e.JSJB == 0).Count(),
SJ1 = p.Where(e => e.JSJB == 1).Count(), //市级竞赛1数
SJ2 = p.Where(e => e.JSJB == 2).Count(), //市级竞赛2数
SJ3 = p.Where(e => e.JSJB == 3).Count(), //市级竞赛3数
SJ4 = p.Where(e => e.JSJB == 4).Count(), //市级竞赛4数
XJJS = p.Where(e => e.JSJB == 5).Count(),//县级竞赛数
Sum = p.Where(e => e.JSJB == 0).Count() +
p.Where(e => e.JSJB == 1).Count() +
p.Where(e => e.JSJB == 2).Count() +
p.Where(e => e.JSJB == 3).Count() +
p.Where(e => e.JSJB == 4).Count() +
p.Where(e => e.JSJB == 5).Count()
};
return query;
data应该是在内存中的一个集合吧?
看这情况应该你想把内存中的集合和数据中的表做表连接造成的
谢谢你的答复
如果我硬要将内存表和数据中的表做连接呢?有什么解决方案??本人也遇到相同的问题,求指导!
var asd = from a in ds.Tables[n2].AsEnumerable()
select a.ItemArray[random];
var tempseat = from t in db.temporary
select new
{
车次 = t.车次,
车厢号 = t.车厢号,
车厢类型 = t.车厢类型,
行 = t.行,
列 = t.列
};
var test = tempseat.Intersect(asd);//交集,我的目的就是内存表和表做交集
return test;