1对1
对象
public class Users { public int id { get; set; } public string name { get; set; } } public class Book { public int id { get; set; } public string bookname { get; set; } public int userid { get; set; } public Users user { get; set; } }
查询
var res = conn.Query<Book, Users, Book>("select * from book as b left join user as u on b.userid=u.id", (b, u) => { b.user = u; return b; }).ToList();