我有以下两个类和相应的数据库表.我试图插入完整的对象图(学生有多个课程).我正在寻找一个如何使用Dapper来做这个的例子.Id是自动增量标识字段.
public class Student
{
public int Id {get;set;}
public string Name {get;set;}
public IEnumerable<Course> Courses {get;set;}
}
public class Course
{
public int Id {get;set;}
public string Name {get;set;}
}
Run Code Online (Sandbox Code Playgroud)
学生
ID [int](pk)
姓名[varchar(50)]
StudentCourse
StudentId [int](fk)
CourseId [int](fk)
课程
ID [int](fk)
姓名[varchar(50)]
我有以下类和数据库模式.我试图使用dapper从数据库中查询这些数据,这将使整个对象图水合.我查看了各种SO问题和测试,但无法弄清楚如何做到这一点.
Author
-AuthorId
-Name
Post
-PostId
-Content
-AuthorId
Comment
-PostId
-CommentId
-Content
Tag
-PostId
-TagId
-Name
Run Code Online (Sandbox Code Playgroud)
public class Author
{
public int AuthorId { get; set; }
public string Name { get; set; }
}
public class Tag
{
public int PostId { get; set; }
public int TagId { get; set; }
public string Name { get; set; }
}
public class Post
{
public int PostId { get; set; }
public string Content { get; …Run Code Online (Sandbox Code Playgroud)