dapper多表查询

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();
              

 

上一篇:63. python高级------javaScript(1)


下一篇:Android开发——Fragment知识整理(一)