I have an object Style
with a property StockNumber
. I would like to filter a list of all Db.Styles
against an IEnumerable
You can think of Intersect
as effectively a Join
where the keys of each object are always "themselves". Here you want to perform a join where the key isn't always "itself", so you use a Join
(or, if you need to remove duplicates, a GroupJoin
).
var query = from style in Db.Styles
join number in stockNumbers
on style.StockNumber equals number
into numbers
where numbers.Any()
select style;