码迷,mamicode.com
首页 > 数据库 > 详细

Linq to Sql/entity Join

时间:2015-05-22 16:49:40      阅读:116      评论:0      收藏:0      [点我收藏+]

标签:

?

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};

?

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

Linq to Sql/entity Join

标签:

原文地址:http://www.cnblogs.com/pengzhen/p/4522521.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!