title: Inserting with Dapper.Contrib and DynamicParameters
body: <p><strong>QUESTION :</strong></p>
  
  <p><strong>Is there a clever way to dynamically add parameters to an object and insert them in to a SQL DB?</strong></p>
  
  <p>preferably using Dapper</p>
  
  <hr>
  
  <p>I'm writing a WPF app where (amongest other things) I'm collecting questionnaire data. I'm using Dapper to map c# objects to SQL statements. </p>
  
  <p>My problem is that I don't want to hard code all of the column names as object properties since I have a lot of them!</p>
  
  <p>So I wanted to use Dapper's <code>DynamicParameters</code> to dynamically generate objects that Dapper can insert into the database by using the Dapper.Contrib <code>Insert</code> method.</p>
  
  <p>I made an abstract class like this: </p>
  
  <pre><code>public abstract class IDbRecord : DynamicParameters
      {
          [Key]
          public string H4Id { get; set; }
      }
  </code></pre>
  
  <p>and added parameters in another method using the <code>DynamicParameters.Add</code> method.</p>
  
  <p>When my parameters have been added to my <code>IDbRecord</code> derived object I try to insert it.</p>
  
  <p>This results is the <code>Insert</code> medthod trying to insert the public properties of <code>DynamicParameters</code> and not the content of the private <code>parameters</code> Dictonary. Which makes sense when looking at the Readme of Dapper.Contrib. I was just hoping that they had implemented <code>Insert()</code> to grab the <code>parameters</code> Dictonary when the object was derived from <code>DynamicParameters</code>.</p>