Filter a List via Another
Posted
by
user1166905
on Stack Overflow
See other posts from Stack Overflow
or by user1166905
Published on 2012-12-17T22:33:43Z
Indexed on
2012/12/17
23:03 UTC
Read the original article
Hit count: 202
I have a requirement to filter a list of Clients based on if they haven't had any jobs booked in the last x months. In my code I have two lists, one is my Clients and the other is a filtered List of Jobs between today and x months ago and the idea is to filter Clients based on their id not appearing in the jobs list. I tried the following:
filteredClients.Where(n => jobsToSearch.Count(j => j.Client == n.ClientID) == 0).ToList();
But I seem to get ALL clients regardless. I can easily do a foreach but this severly slows down the process. How can I filter the client list based on the job list effectively?
© Stack Overflow or respective owner