美文网首页linq
Join & Left Join

Join & Left Join

作者: 落地成佛 | 来源:发表于2018-01-10 21:54 被阅读13次

1、Join

1.1定义

image.png

1.2结果

image.png

2、Left Join

2.1定义

    var list = (from teacher in teachers
                join student in students on teacher.TeacherId equals student.TeacherId into temp
                from tt in temp.DefaultIfEmpty()
                select new
                {
                   teacherName = teacher.TeacherName,
                   studentName = tt?.StudentName
                }).Dump("查询语句");

2.2结果

image.png

相关文章

网友评论

    本文标题:Join & Left Join

    本文链接:https://www.haomeiwen.com/subject/ycwonxtx.html