Reputation: 1945
I need to select 2 different categories from same table using EF with LINQ in C#
Like:
_tour.Products.Where(na => na.ProductCategory.ProductCategoryID == 1 && na.ProductCategory.ProductCategoryID == 6);
this works if I do use != to filer these categories from another list selected from the same table..just not able to select only these two categories. Can anybody help??
Upvotes: 1
Views: 49
Reputation: 125650
There is no way for a category to have ID == 1
AND ID == 6
at the same time. Use OR instead:
_tour.Products.Where(na => na.ProductCategory.ProductCategoryID == 1 || na.ProductCategory.ProductCategoryID == 6);
Upvotes: 3