This question is locked. New answers and comments are not allowed.
Hi,
I noticed that when I tried to update the database in that way (copy an object to another), it does not work and the database is not updated
public static void UpdateEmployee(Employee employee) |
{ |
scope.Transaction.Begin(); |
Employee employeeToEdit = GetEmployeeById(employee.Id); |
employeeToEdit = employee; // Copies emplyee's properties to employeeToEdit's properties |
scope.Transaction.Commit(); |
} |
But if I try to update the database by setting each property of the destination objet with the ones from the source object, the database gets updated...
public static void UpdateEmployee(Employee employee) |
{ |
scope.Transaction.Begin(); |
Employee employeeToEdit = GetEmployeeById(employee.Id); |
employeeToEdit.FirstName = employee.FirstName ; |
employeeToEdit.LastName = employee.LastName; |
scope.Transaction.Commit(); |
} |
Is it possible to simply copy the source object to the destination object ? That would save the hassle of setting each property one by one...
Thanks for your help.
Regards.