Using LINQ, how can I find a list of items where it\'s list of components contains a component from another list of components?
Structure:
class Item
{
It because Any
expects boolean value, but you return string: x.Name.ToString
.
You can check intersection of two sequences in you case:
items.Where(x => x.Components.Intersect(components).Any())
Intersect
will return non-empty sequence, if both item.Components
and components
contain same elements. Then Any
without parameters will return true
, if the sequence is non-empty.