title: Dapper Dynamic Parameters with Table Valued Parameters
body: <p>I was trying to create a generic method, which can read the parameters name and value from a class at Runtime and create parameter collection for Dapper query execution. Realized that till the point all parameters are Input type it works well, but if I have to add an <code>Output / ReturnValue</code> type parameters, then I need to work with <code>DynamicParameters</code>, else I cannot fetch the value of <code>Output / ReturnValue</code> parameters</p>
  
  <p>SP has following parameters:</p>
  
  <pre><code>PersonList - TableValued - Input
  TestOutput - Int - Output
  </code></pre>
  
  <p>I am not able to make following piece of code work:</p>
  
  <pre><code>var dynamicParameters = new DynamicParameters();
  dynamicParameters.Add("PersonList", &lt;DataTable PersonList&gt;);
  dynamicParameters.Add("TestOutput", 0, Dbtype.Int32, ParameterDirection.Output);
  </code></pre>
  
  <p>Exception is:</p>
  
  <blockquote>
    <p>System.Data.SqlClient.SqlException: The incoming tabular data stream (TDS)
         remote procedure call (RPC) protocol stream is incorrect. Parameter 1 
        ("@PersonList"): Data type 0x62 (sql_variant) has an invalid type for type-
        specific metadata.</p>
  </blockquote>
  
  <p>Issue as I can understand is there's no valid DbType available for adding a TVP to the Dynamic Parameters, since I am not using the SqlDbType, so there's no replacement for SqlDbType.Structured in the DbType.</p>
  
  <p>Any pointer or workaround to resolve the issue</p>