コード例 #1
0
 private void ReflectionToSetUpdatedValues(Employee original, Employee updatedUser)
 {
     foreach (PropertyInfo propertyInfo in original.GetType().GetProperties())
     {
         if (propertyInfo.GetValue(updatedUser, null) == null)
         {
             propertyInfo.SetValue(updatedUser, propertyInfo.GetValue(original, null), null);
         }
     }
     BusinessContext.Attach(updatedUser);
     BusinessContext.Entry(updatedUser).State = EntityState.Modified;
     BusinessContext.SaveChanges();
 }