Linq to Sql/entity Join

 

inner join 模板:

  1. var query = from x in db.T1
  2.             join y in db.T2
  3.             on x.Id equals y.Id
  4.             select x;

 

left join模板:

 

  1. var query = from x in db.T1
  2.             join y in db.T2
  3.             on x.yId equals y.Id into temp
  4.             from ret in temp.DefalutIfEmpty()
  5.             select new{ x.Id, ret};

 

经常记不住,这次把它记下来!

上一篇:Django Admin 简单部署上线


下一篇:pip更新已经安装的库