I have such class:
public class Item
{
public int Id {get;set;}
public string A {get;set;}
public string B {get;set;}
public string C {get;set;}
}
And now I have an example dictionary which looks like this:
var dict = new Dictionary<<int, List<Item>>()
{
{
1,
new List<Item>()
{
new Item { Id = 1, A = "aaa", B = "bbb", C = "ccc" },
new Item { Id = 2, A = "q", B = "w", C = "e" }
}
},
{
2,
new List<Item>()
{
new Item { Id = 3, A = "aaa", B = "bbb", C = "ccc" },
new Item { Id = 4, A = "qqq", B = "www", C = "eee" }
}
},
{
3,
new List<Item>()
{
new Item { Id = 1, A = "aaa", B = "bbb", C = "ccc" },
new Item { Id = 5, A = "some", B = "other", C = "case" }
}
},
};
What I need to do is to find all Item's which have equal values on properties A, B, C for ALL keys, so as an output there should be an IEnumerable<Item> / List<Item>.
For the example above, the output would contain a single Item element with values:
A = "aaa", B = "bbb", C = "ccc"
because for each dictionary key an Item object with those exact values exist.
Id for this object could be taken from first Item that matches, so it could be equal to 1
How would a LINQ query look for this?