title: What's the best way to save a one-to-many relationship in Linq2Sql?
body: <p>I'm trying to figure out the best way to save a simple one-to-many relationship in Linq2Sql.</p>
  
  <p>Lets assume we have the following POCO model (pseduo code btw):</p>
  
  <p><em>Person has zero to many Vechicles.</em></p>
  
  <pre><code>class Person
  {
      IList&lt;Vehicle&gt; Vehicle;
  }
  
  class Vehicle
  {
      string Name;
      string Colour;
  }
  </code></pre>
  
  <p>Now, when i save a Person, i pass that poco object to the repository code (which happens to be L2S). I can save the person object fine. I usually do this.</p>
  
  <pre><code>using (Db db = new Db())
  {
      var newPerson = db.People.SingleOrDefault(p =&gt; p.Id == person.Id) ?? new SqlContext.Person();
      // Left to right stuff.
      newPerson.Name = person.Name;
      newPerson.Age = person.Age;
  
      if (newPerson.Id &lt;= 0)
          db.People.InsertOnSubmit(newPerson);
      db.SubmitChanges();
  }
  </code></pre>
  
  <p>i'm not sure where and how i should handle the list of vehicles the person might have? any suggestions?</p>