码迷,mamicode.com
首页 > 其他好文 > 详细

EF的连表查询Lambda表达式

时间:2015-07-06 09:59:35      阅读:243      评论:0      收藏:0      [点我收藏+]

标签:

var lst = from c in db.Blogs join p in db.Posts on c.Id equals p.BlogId where p.Id==1 select c;
var lst1 = db.Blogs.Join(db.Posts.Where(p=>p.Id==1), b=> b.Id, p=> p.BlogId, (b, p) => new {b});
 public class Blog
 {
    public int Id { get; set; }
    public string Title { get; set; }
 }


 public class Post
 {
    public int Id { get; set; }
    public string Title { get; set; }
    public int BlogId { get; set; } 
 }

 

EF的连表查询Lambda表达式

标签:

原文地址:http://www.cnblogs.com/tinya/p/4623503.html

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