I took a look at this answer and it goes in part to solving my issue.
However, what I need is the following.
Given I have an object;
Product
string code
List<suitability> items
and then i have this object;
Suitability
key
value
Each Product has a variable amount of [items] and the key/value pairs differ from product to product.
When searching I am given a list of Suitability objects. I now need to search all the products that contain (all) of the supplied suitability objects.
So for example a product may have dental = true and therapies = true.
I may get a request for all products that have dental = true and therapies = false.
Using PredicateBuilder (from the authors of LinqPad) you can build up a query from a set of conditions not known at compile time. The following should be sufficient:
UPDATE: Heres some sample code that I have tested which works using an IEnumerable as the source, the resulting set
productsResultcontains the first and second products inproductslist: