title: Data Binding from FormCollection to Model
body: <p>I am trying to bind data received from my view to a specific model. I want to translate the form data into a dictionary object. This is accomplished using a generic method I developed, TranslateFormData. This is where I am having issues.</p>
  
  <p>Here is the controller code:</p>
  
  <pre><code>[HttpPost]
  public System.Web.Mvc.ActionResult SubmitDecision ( FormCollection formData )
  {
      Dictionary&lt;string, string&gt; data = FormData.TranslateFormData ( formData );
      TPDispatcherNetClient client = new TPDispatcherNetClient ( );
  
      *Additional code left out for brevity*        
  
      return View ( );
  }
  </code></pre>
  
  <p>This line, <code>Dictionary&lt;string, string&gt; data = FormData.TranslateFormData ( formData );</code>, is causing me issues. Here is the code for TranslateFormData:</p>
  
  <pre><code>public static Dictionary&lt;string, string&gt; TranslateFormData&lt;T&gt; ( T form ) where T : IEnumerable&lt;KeyValuePair&lt;string, string&gt;&gt;
  {
      Dictionary&lt;string, string&gt; data = new Dictionary&lt;string, string&gt; ( );
      IEnumerator&lt;KeyValuePair&lt;string, string&gt;&gt; pairs = form.GetEnumerator ( );
  
      return data;
  }
  </code></pre>
  
  <p>Passing in the FormCollection is producing the following error:</p>
  
  <blockquote>
    <p>The type 'System.Web.Mvc.FormCollection' cannot be used as type parameter 'T' in the generic type or method 'TranslateFormData(T)'. There is no implicit >reference conversion from 'System.Web.Mvc.FormCollection' to 'System.Collections.Generic.IEnumerable>'</p>
  </blockquote>
  
  <p>How can I accomplish this? I want avoid changing TranslateFormData to accept a specific type and then overloading based on all expected types if at all possible.</p>
  
  <blockquote>
    <p>EDIT
    Since initially writing this question I have modified my translation method accordingly:</p>
  </blockquote>
  
  <pre><code>public static CustomerDecisionRequest TranslateFormData&lt;T&gt; ( T form ) where T : NameValueCollection, IEnumerable
  {
      CustomerDecisionRequest request = new CustomerDecisionRequest ( );
      IEnumerator enumerator = formData.GetEnumerator ( );
  
      return request;
  }
  </code></pre>
  
  <p>So, while the above questions stands, does this modification make sense and is it appropriate?</p>