title: Child action - adding multiple elements to
body: <p>I have a child action with the following code snippet:</p>
  
  <pre><code>public ActionResult MyAction()
  {
      var models = GetModelsFromDb();
      var counts = new Dictionary&lt;int, int&gt;();
  
      foreach (var model in models)
          if (!counts.ContainsKey(model.Id))
              counts.Add(model.Id, 0);
  
      return View(count);
  }
  </code></pre>
  
  <p>The problem is that... <code>Add</code> sometimes throws <code>An item with the same key has already been added.</code> exception.
  Could it be concurrency problem? I don't think since the code is in child action, and the dictionary is the local variable.</p>