Query Nested Dictionary
c#, dictionary, linq
Solution
var result = dict[someInt].MinBy(kvp => kvp.Value.value1 + kvp.Value.value2).Key;
using the MinBy Extension Method from the awesome MoreLINQ project.
Problem
I was curious if anyone had a good way to solving this problem efficiently. I currently have the following object. ``` Dictionary<int, Dictionary<double, CustomStruct>> struct CustomStruct { double value1; double value2; ... } ``` Given that I know the 'int' I want to access, I need to know how to return the 'double key' for the dictionary that has the lowest sum of (value1 + value2). Any help would be greatly appreciated. I was trying to use Linq, but any method would be appreciated.