title: Generic method for comparing 2 objects and update changes from one to the other in c#
body: <p><strong>Problem case:</strong> </p>
  
  <p>My problem is editing disconnected POCO entities and then saving them to the database (Uisng Entity Framework). When doing so, the generated sql updates ALL properties even though only some have actually changed. When I do the same within the context, the generated sql correctly updates only the modified properties. This causes problem with my auditing code since it wrongly stores changes on all the properties. This is made worst when the entity I am persisting has a complicated model with many relationships.</p>
  
  <p><strong>My proposed solution:</strong></p>
  
  <p>Instead of attaching the modified entity to the context, I want to query the entity and then manually syncronize the two object with a generic method that will work for any model. So I need to compare all properties from each object and update the modified properties to the attached entity. How do I go about updating the values in the properties, keeping in mind that changes might include new or modified relationships ?</p>
  
  <p>Any thoughts?</p>