title: Group dictionary to other dictionary via intermediate map
body: <p>I have a dictionary that map between certain keys</p>
  <pre><code>var map = new Dictionary&lt;string, string&gt;(){ {&quot;A&quot;, &quot;One&quot;}, {&quot;B&quot;, &quot;One&quot;}, {&quot;C&quot;, &quot;Two&quot;} };
  </code></pre>
  <p>I also have a dictionary containing values</p>
  <pre><code>var values = new Dictionary&lt;string, double&gt;() { {&quot;A&quot;, 2.0}, {&quot;B&quot;, 1.0}, {&quot;C&quot;, 1.0} };
  </code></pre>
  <p>I want to map the values into a third dictionary so that the value of <code>map</code> is the key of the new dictionary. I.e. I want the new dictionary to be</p>
  <pre><code>var result = new Dictionary&lt;string, double&gt;() {{&quot;One&quot;, 3.0}, {&quot;Two&quot;, 1.0}};
  </code></pre>
  <p>This can of course be achieved using loops like so</p>
  <pre><code>var result = new Dictionary&lt;string, double&gt;();
  foreach (var kv in values)
  {
      var key = map[kv.Key];
      var value = kv.Value;
  
      if (result.TryGetValue(key, out var temp))
          result[key] = value + temp;
      else
          result.Add(key, value);
  }
  </code></pre>
  <p>Or something like that...</p>
  <p>But is it possible to do this in a one-liner using linq?</p>