score:100

Accepted answer

Try this:

var filtered = listOfAllVenues
                   .Where(x=>!listOfBlockedVenues.Any(y=>y.VenueId == x.Id));

It will get all Venues where Id is not in blockedVenues list

score:0

As of NET 6, you can use ExceptBy.

var filtered = allVenues.ExceptBy(blockedVenues.Select(x => x.VenueID), venue => venue.ID);

This will get all venues except those whose ID is in blockedVenues.Select(x => x.VenueID)

https://docs.microsoft.com/en-us/dotnet/api/system.linq.enumerable.exceptby?view=net-6.0


Related Query

More Query from same tag