Convert SQL to Linq left join with null

前端 未结 4 737
臣服心动
臣服心动 2020-12-08 09:10

How can I convert properly this SQL to linq

select  t1.ProgramID
from Program t1 LEFT JOIN ProgramLocation t2 ON  t1.ProgramID = t2.ProgramID 
where t2.Progr         


        
4条回答
  •  执念已碎
    2020-12-08 09:41

    Try this

      var progy = (
             from u in db.ProgramLocations join b in db.Programs
             on u.ProgramID equals b.ProgramID into yG 
             from y1 in yG.DefaultIfEmpty() 
             where y1 == null
             select u.ProgramID
            ).ToList();
    

    You can check this post on MSDN.

    Hope this works for you.

提交回复
热议问题