首页 新闻 会员 周边 捐助

Linq 左连接 查询

0
悬赏园豆:30 [已关闭问题] 关闭于 2016-06-20 15:15
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();
满满的记忆的主页 满满的记忆 | 初学一级 | 园豆:126
提问于:2015-09-15 16:41
< >
分享
所有回答(1)
0

。。。

满满的记忆 | 园豆:126 (初学一级) | 2016-06-20 15:15
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册