I have two Lists like so:
List<EmpData> colExistingEmpData;
List<EmpData> colExternalEmpData;
Each of them will have employee records that have the same Id. I know this sounds wierd but that's a real situation I am in right now!
For every employee in colExternalEmpData based on EmpId a check is made on colExistingEmpData
foreach (EmpData employee in colExternalEmpData)
{
var queryResult = colExistingEmpData.FindAll(thisEmployee => thisEmployee.Id == employee.Id);
if(querResult.count == 0)
{
// Mark as INSERT
}
else if(querResult.count == 1)
{
// Mark as UPDATE
}
else // queryResult is more than 1
{
// data is duplicated mark as IGNORE
}
analysedData.Add(employee);
This works fine when colExistingEmpData has no duplicated value for the 'Id'
When there are duplicates in colExternalEmpData, meaning if two employees have same 'ID' as 123 the above code will still mark the existing employee with 123 id as update because it finds an exact match in colExistingEmpData provided colExistingEmpData has just one reocrd with that Id.
Is there a way in which an employee record can be marked as 'IGNORE' when it's repeated in either of the sources?
I can't use a Dictionary object, I had used it before but the powers that be didn't like the idea.
Regards.