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对多

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
  • 2021-09-17
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-07-26
  • 2022-02-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案