//多表查询 两种方法生成的SQL语句是一模一样

//方法一

var query1 = from a in db.as
from b in db.bs.Where(b => b.Id == a.Id)  
from c in db.cs.Where(c => c.Id== b.Id).DefaultIfEmpty()  
from d in db.ds.Where(d => d.Id== c.Id).DefaultIfEmpty()  
select new{}

//方法二  
var query2 = from a in db.as
join b in db.bs on b.Id equals a.Id
join c in db.cs on c.Id equals b.Id into ac  
join d in db.ds on d.Id equals c.Id into ad 
from c in ac.DefaultIfEmpty()
from d in ad.DefaultIfEmpty() 
select new{}

Inner join:

var query = from a in db.as
from b in db.bs
from c in db.cs
where as.Id==bs.Id && bs.Id=cs.Id
select new{}

相关文章:

  • 2022-12-23
  • 2021-10-14
  • 2022-01-26
  • 2021-11-07
  • 2022-12-23
  • 2021-07-24
  • 2021-09-09
  • 2022-01-10
猜你喜欢
  • 2021-07-24
  • 2021-07-07
  • 2022-12-23
  • 2022-12-23
  • 2021-12-22
  • 2021-11-18
  • 2021-12-09
相关资源
相似解决方案