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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top