Struggling to get my head around this query and need a little help.
I have a List of items and I need to refine it down to a collection which meets two criteria.
For example
Collection of this class:
FakeClass
public int code { get; set;}
public int qty {get; set}
I have a list of items which I want to extract Which would be <code, qty>
I need to pull out all entries which match both the same code and qty
For example:
List<FakeClass> collection = {
{1, 1}
{2, 2}
{3, 1}
{1, 3}
List<int, int> to match
{1,1}
{1,2}
{1,3}
I only want to get 1,1 & 1,3 out of the collection.
Any thoughts?
CodePudding user response:
As Cid has said, the Dictionary in your example isn't valid. Assuming it was, best as I can tell from your example you just want something which filters the collection:
collection.Where(f => temp.containsKey(f.code) ? temp[f.code] == f.qty : false);