SELECT SI_2.[StudGUID] ,SI_2.[ClassName], SI_2.[StudGUID],SI_1.[StuName],SI_1.[Title],SI_1.[StuMobileNumber] FROM [StudentInfo2] AS SI_2 INNER JOIN [StudentInfo] AS SI_1 ON SI_2.[StudGUID]=SI_1.[StuCode] WHERE SI_2.[ClassID] IN ( SELECT SC.[ClassID] FROM [SchoolClass] AS SC LEFT JOIN [BookClass] AS BC ON SC.[ClassID]=BC.[ClassID] WHERE BC.[ClassID] IS NULL AND SchoolYear=2015 ) AND SI_2.[isMonitor]=1
怎么把上面的SQL 语句 用Linq 表示啊? 求助求助!
下面是我写,我不知道为什么错了?
var a = (from sc in context.SchoolClass.Where(s => s.ClassID == null
&& s.SchoolYear.Equals(2015)) join bc in context.BookClass on sc.ClassID equals bc.ClassID into temp from tt in temp.DefaultIfEmpty() select new { ClassID = sc.ClassID }).ToString(); query = (from s2 in context.StudentInfo2 join s1 in context.StudentInfo on s2.StudGUID equals s1.StuCode where a.Contains(s2.ClassID) orderby s1.SysCreationTime descending select new StudentInfoList { StudGUID = s2.StudGUID, ClassName = s2.ClassName, StuName = s1.StuName, Title = s1.Title, StuMobileNumber = s1.StuMobileNumber }).Skip(pageIndex - 1).Take(pageSize).ToList();
。。。