Reputation: 451
I have the following populated lists:
List<Item> Items
List<long> QueueID
Where Item is this:
public Class Item
{
long QueueID
....
}
I need to make a new List of Items that excludes Items with QueueIDs that are in the other List.
I'm trying this but the compiler doesn't like it.
var result = Items.Where(x => !QueueID.Exists(x => x.QueueID));
Upvotes: 1
Views: 23
Reputation: 460138
You can use this approach using List.Contains
:
List<Item> resultList = Items.Where(x => !QueueID.Contains(x.QueueID)).ToList();
Upvotes: 2