IQueryable Where - Equivalent to IN in SQL?

Joined
Mar 7, 2009
Messages
1
Reaction score
0
I need to do the following.

Find all Products from a product list, that are in any of the sub categories in a list.

The product object has many sub categories.

I tried

products.Where(x => x.SubCategories.Any(sc => subCategories.Contains(sc)));

(subCategories - is a list of possible sub categories)

This doesnt work, it throws a null refrence exception. im not sure why.

Any Help?
 
Back
Top