欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

EFCore中 join on的不同

程序员文章站 2022-04-08 19:21:48
当 多条件 left join on 时 LEFT OUTER JOIN on new { u.UserId, ue.ExamId } equals new { sac.UserId, sac.ExamId } into sac2 from sac in sac2.DefaultIfEmpty() ......

当 多条件 left join on 时

left outer join

on new { u.userid, ue.examid } equals new { sac.userid, sac.examid }
into sac2
from sac in sac2.defaultifempty()

生成sql 为 

 on ([filter1].[userid1] = [groupby1].[k1]) and (([filter1].[examid2] = [groupby1].[k2]) or (([filter1].[examid2] is null) and ([groupby1].[k2] is null)))

单条件 on 时 

sql on 没有空值判断

  left outer join [dbo].[sysquestion] as [extent3] on [groupby1].[k1] = [extent3].[queid]