title: Best way to update a LINQ model coming from a form
body: <p>I'm designing forms in my ASP.NET MVC application that will receive objects. Here's what a typical edit action looks like:</p>
  
  <pre><code>    [AcceptVerbs(HttpVerbs.Post)]
      public ActionResult Edit(int id, Person person)
      {
          peopleService.SavePerson(person);
          return Redirect("~/People/Index");
      }
  </code></pre>
  
  <p>The <code>SavePerson</code> call in the service does this:</p>
  
  <pre><code>    public void SavePerson(Person person)
      {
          _peopleRepository.SavePerson(person);
      }
  </code></pre>
  
  <p>And the <code>SavePerson</code> call in the repository does this:</p>
  
  <pre><code>    public void SavePerson(Person person)
      {
          using (var dc = new SIGAPDataContext())
          {
              if (person.IsNew)
              {
                  dc.People.InsertOnSubmit(person);
              }
              else
              {
                  dc.People.Attach(person, true);
              }
  
              dc.SubmitChanges();
          }
      }
  </code></pre>
  
  <p>Now, this works well when I create the new record. However, when I update it without all the form elements, it nulls other fields. For instance, my Person model has a NationalityID property that is nulled if it doesn't show on the edit form.</p>
  
  <p>What's the best practice to make the model update with just the fields that come from the form? Do I have to get the record from the database first and update it's properties manually like:</p>
  
  <pre><code>Person persistedPerson = peopleService.GetPerson(person.ID);
  persistedPerson.Name = person.Name;
  persistedPerson.DateOfBirth = person.DateOfBirth
  // etc...
  </code></pre>
  
  <p>Or is there any other, cleaner way to do this?</p>