I want to create, update and delete records from two data sources, a CSV file and a database.
Each items are loaded in a specific model :
List<Employee> fromEmployees = this.loadCSVEmployees();
List<Employee> toEmployees = this.loadDBEmployees();
And I use Except and Intersect to compares values :
List<Employee> empToDelete = toEmployees.Except(fromEmployees, new EmpEqualityComparer()).ToList();
List<Employee> empToCreate = fromEmployees.Except(toEmployees, new EmpEqualityComparer()).ToList();
List<Employee> empToUpdate = fromEmployees.Intersect(toEmployees, new EmployeeIntersetComparer()).ToList();
empToUpdate contain the values I want to update (so from fromEmployees) but the ID of the records is set in the toEmployees list.
What is the best method to merge some values (like the identity) from the two list on the intersect result ? The employee model has a SSNO I use to know identical users... I cant use union.