I have a couple of generic list one with more than 70,000 items and another one with 10 items. I have to find out the items that are not there in second list when comparing with first list. Logically, my code is working fine and I don't face any serious performance issues with smaller set of list. As my first list is more than 70K items, i am facing serious of performance issue. It takes lot of time to execute and get the result.
My question is? Is there any better way of doing this? I cannot live with this performance issue. any suggestions for improvement? I am using C#, .NET 3.5
List<Employee> existingEmployeeList = List of 70K employees;
List<Employee> validEmployeeList = List of 10 employees;
var emloyeeDeletedFilterList = existingEmployeeList.Where(m => !validEmployeeList.Any(p => p.EmployeeId == m.EmployeeId
&& p.FirstName == m.FirstName
&& p.Age == m.Age
&& p.LastName == m.LastName));
I have another operations to find which are newly added to list.
var emloyeeAddedFilterList = validEmployeeList.Where(m => !existingEmployeeList.Any(p => p.EmployeeId == m.EmployeeId
&& p.FirstName == m.FirstName
&& p.Age == m.Age
&& p.LastName == m.LastName));
I have 4 conditions in the where clause to filter employee list.
Edited my question: added one more code snippet