I have following two classes and corresponding db tables. I am trying to insert the full object graph (student with multiple courses). I am looking for an example on how would one do this using Dapper. The Id's are auto-increment identity fields.
Class
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;}
}
Table
Student
Id [int] (pk)
Name [varchar(50)]
StudentCourse
StudentId [int] (fk)
CourseId [int] (fk)
Course
Id [int] (fk)
Name [varchar(50)]