title: Inserting One to Many Entities using dapper
body: <p>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.</p>
  
  <h2>Class</h2>
  
  <pre><code>public class Student
  {
      public int Id {get;set;}
      public string Name {get;set;}
      public IEnumerable&lt;Course&gt; Courses {get;set;}
  }
  public class Course
  {
      public int Id {get;set;}
      public string Name {get;set;}
  }
  </code></pre>
  
  <h2>Table</h2>
  
  <p><b>Student</b><br/>
  &nbsp;&nbsp;Id [int] (pk)<br/>
  &nbsp;&nbsp;Name [varchar(50)]<br/>
  <br/></p>
  
  <p><b>StudentCourse</b><br>
  &nbsp;&nbsp;StudentId [int] (fk)<br />
  &nbsp;&nbsp;CourseId  [int] (fk)<br />
  <br /></p>
  
  <p><b>Course</b><br/>
  &nbsp;&nbsp;Id   [int] (fk)<br/>
  &nbsp;&nbsp;Name [varchar(50)] <br/></p>