码迷,mamicode.com
首页 > 移动开发 > 详细

Dapper多表查询

时间:2016-04-20 22:03:40      阅读:755      评论:0      收藏:0      [点我收藏+]

标签:

1对1

 

//文章
public class Post
        {
            public int ID { get; set; }
            public string Title { get; set; }
            public string Body { get; set; }
            //一篇文章只对应一个作者
public int AuthorID{get;set;}
public Author Author { get; set; } } //作者 public class Author { public int ID { get; set; } public string Name { get; set; } }
var data = cnn.Query<Post, Author, Post>(@"select * from Posts p left join Authors a on a.ID = p.AuthorID", (post, author) => { post.Author = author; return post; },splitOn:"ID").ToList();

 

1对多

 

Dapper多表查询

标签:

原文地址:http://www.cnblogs.com/imust2008/p/5414424.html

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