title: EditorFor() and additionalViewData: how to add data in helper class?
body: <p>EditorFor() can take an <code>object additionalViewData</code> parameter which the typical method to populate is something like:</p>
  
  <p><code>EditorFor(model =&gt; model.PropertyName, new { myKey = "myValue" })</code></p>
  
  <p>How can I inspect the contents of additionalViewData, add or append to existing value for a key, etc in a custom HTML Helper?</p>
  
  <p>I've tried these approaches:</p>
  
  <ul>
  <li>convert to <code>Dictionary&lt;string, object&gt;()</code> and add/append values: doesn't work as it looks like the implementation of EditorFor in MVC uses new RouteValueDictionary(additionalViewData) which embeds the dictionary within a dictionary</li>
  <li>convert to RouteValueDictionary using <code>new RouteValueDictionary(additionalViewData)</code> but that has same (or very similar) issue as above</li>
  </ul>
  
  <p>I'm also open to "you're doing it wrong" -- maybe I'm missing a simpler approach. Keep in mind what I'm trying to do is write an HTML helper that is reusable and adds some values to the additionalViewData to be used by custom views. Some of the values depend on metadata from the property so it is not quite so easy as just use a bunch of different templates.</p>
  
  <p>Update with example of what I'm doing:</p>
  
  <pre><code>    public static MvcHtmlString myNullableBooleanFor&lt;TModel, TValue&gt;(this HtmlHelper&lt;TModel&gt; htmlHelper, Expression&lt;Func&lt;TModel, TValue&gt;&gt; choice, string templateName, object additionalViewData)
      {            
          ModelMetadata metadata = ModelMetadata.FromLambdaExpression(choice, htmlHelper.ViewData);
  
          /*
      here need to add to additionalViewData some key values among them:
      { propertyName, metadata.PropertyName }
  
       */
  
          StringBuilder sb = new StringBuilder();
          sb.AppendLine(htmlHelper.EditorFor(choice, templateName, additionalViewData).ToString());
          MvcHtmlString validation = htmlHelper.ValidationMessageFor(choice);
          if (validation != null)
              sb.AppendLine(validation.ToString());
          return new MvcHtmlString(sb.ToString());
      }
  </code></pre>
  
  <p>Update with what happens when I convert the anonymous object to a <code>Dictionary&lt;string, object&gt;()</code> and pass that dictionary to <code>EditorFor()</code>:</p>
  
  <p>I put a break point in the Razor view and examined ViewData. It appears that the dictionary passed into <code>EditorFor()</code> is put inside another <code>Dictionary&lt;string, object&gt;()</code>. In the "Immediate Window", ViewData looks like this:</p>
  
  <pre><code>ViewData.Keys
  Count = 4
      [0]: "Comparer"
      [1]: "Count"
      [2]: "Keys"
      [3]: "Values"
  </code></pre>
  
  <p>See how the dictionary has the contents of a dictionary within it? Yes, the actual data is in that inner dictionary however unsurprisingly, this doesn't work.</p>
  
  <p>Added bounty.</p>