I have the following classes:
Product:
public class Product
{
public string Name { get; set; }
public List<Category> Categories { get; set; }
}
And Category:
public class Category
{
public string Id { get; set; }
public string Name { get; set; }
}
And I have the following method:
public List<Product> FilterProducts(List<Category> categories)
{
// filtering code here
}
Question: How can I filter my products using a List<Categories>
as parameter?
EDIT: One thing I forgot to mention is that if I have 2 categories I should be able to see only the products with the category1 AND category2. What I've done so far has returned only products with category1 OR category2. Although inherit IEquatable use Intersect seems interesting I am comparing with the Id's for now.