title: Linq to Sql Parent Child
body: <p>ok, so I new to the C# way of doing things, I come from the ruby world. </p>
  
  <p>I have a one to many relationship, (parent to children for sake of this question), and for some reason L2S was wanting to create a new parent instead of using the one is already had. Here is the code.</p>
  
  <pre><code>
  Console.WriteLine(parent.Id); // this equals 1
  foreach (string names in names)
  {
      Child new_child= new Child();
      new_child.Parent = parent;//now parent.Id would equal the next in the sequence.
      new_child.Name= name
  
  
      db.CommitLogs.InsertOnSubmit(new_child);
      db.SubmitChanges();
  }
  </code></pre>
  
  <p>but if I just say</p>
  
  <pre><code>new_child.ParentId = parent.Id
  </code></pre>
  
  <p>that works just fine.</p>
  
  <p>Can someone explain to me whats going on?</p>
  
  <p>PS. Parent was found from the database using L2S. all the keys and such are set up properly. Thanks for any insight.</p>