title: Dapper custom helper (for Table-Valued Parameters) comma instead of dot in floating point value
body: <p>Code from <a href="https://stackoverflow.com/questions/6232978/does-dapper-support-sql-2008-table-valued-parameters">Does Dapper support SQL 2008 Table-Valued Parameters?</a> works great. </p>
  
  <p>But with MSSQL SQL_VARIANT column comes (usually) the trouble...</p>
  
  <pre><code>private static string ConnectionString = @"data source=192.168.1.1;initial catalog=;persist security info=False;user id=sa;password=";
  
  private static void TestTVP2()
      {
          var connection = new SqlConnection(ConnectionString);
          connection.Open();
  
          var nums =
              connection
              .Query&lt;BigIntKeySqlVariantValueType.TypeFields&gt;("[dbo].[pmesAttributeValueUpdate]", new BigIntKeySQLVariantValueTVP(new[]
                      {
                          new BigIntKeySqlVariantValueType.TypeFields{ParameterName = 9976669, ParameterValue= 8.5}
                      }, "@tvp")
                  ).ToList();
  
          foreach (var num in nums)
          {
              Console.WriteLine(num.BigIntKeySqlVariantValueTypeId + " " + num.ParameterName + " " +
                                num.ParameterValue);
          }
      }
  
  
  internal class BigIntKeySQLVariantValueTVP : SqlMapper.IDynamicParameters
  {
      private readonly IEnumerable&lt;BigIntKeySqlVariantValueType.TypeFields&gt; _values;
      private readonly string _parametername;
  
      public BigIntKeySQLVariantValueTVP(IEnumerable&lt;BigIntKeySqlVariantValueType.TypeFields&gt; values, string parametername)
      {
          this._values = values;
          this._parametername = parametername;
      }
  
      public void AddParameters(IDbCommand command)
      {
          var sqlCommand = (SqlCommand)command;
          sqlCommand.CommandType = CommandType.StoredProcedure;
  
          var numberList = new List&lt;SqlDataRecord&gt;();
  
          // Create an SqlMetaData object that describes our table type.
          SqlMetaData[] tvpDefinition =
              {
                  new SqlMetaData(
                      "BigIntKeySQLVariantValueTypeId", SqlDbType.BigInt, true, false, SortOrder.Unspecified, -1),
                  new SqlMetaData("ParameterName", SqlDbType.BigInt),
                  new SqlMetaData("ParameterValue", SqlDbType.Variant),
              };
  
          foreach (var n in _values)
          {
              // Create a new record, using the metadata array above.
              var rec = new SqlDataRecord(tvpDefinition);
  
              rec.SetInt64(1, n.ParameterName); // Set the value.
              rec.SetValue(2, n.ParameterValue);
  
              numberList.Add(rec); // Add it to the list.
          }
  
          // Add the table parameter.
          var p = sqlCommand.Parameters.Add(_parametername, SqlDbType.Structured);
          p.Direction = ParameterDirection.Input;
          p.TypeName = "BigIntKeySQLVariantValueType";
          p.Value = numberList;
      }
  
      public void AddParameters(IDbCommand command, SqlMapper.Identity identity)
      {
          AddParameters(command);
      }
  }
  
  public class BigIntKeySqlVariantValueType 
  {
      /// &lt;summary&gt;
      /// Type POCO
      /// &lt;/summary&gt;
      public struct TypeFields
      {
          public long BigIntKeySqlVariantValueTypeId { get; private set; }
  
          public long ParameterName { get; set; }
  
          public object ParameterValue { get; set; }
      }
  }
  </code></pre>
  
  <p>Here is code generated by Dapper as seen in SQL Profiler:</p>
  
  <pre><code>declare @p1 dbo.BigIntKeySQLVariantValueType
  insert into @p1 values(9976669,8,5)
  exec [dbo].[pmesAttributeValueUpdate] @tvp=@p1
  </code></pre>
  
  <p>My <a href="http://msdn.microsoft.com/en-us/library/bb675163.aspx" rel="nofollow noreferrer">Table-Valued</a> type:</p>
  
  <pre><code>CREATE TYPE [dbo].[BigIntKeySQLVariantValueType] AS TABLE(
      [BigIntKeySQLVariantValueTypeId] [bigint] IDENTITY(1,1) NOT NULL,
      [ParameterName] [bigint] NULL,
      [ParameterValue] [sql_variant] NULL,
      PRIMARY KEY CLUSTERED 
  (
      [BigIntKeySQLVariantValueTypeId] ASC
  )WITH (IGNORE_DUP_KEY = OFF)
  )
  </code></pre>
  
  <p>Code generated by Dapper should be:</p>
  
  <pre><code>insert into @p1 values(9976669,8.5)
  </code></pre>
  
  <p>How to "replace" comma with dot in <code>SqlParameter</code></p>
  
  <pre><code>        // Add the table parameter.
          var p = sqlCommand.Parameters.Add(_parametername, SqlDbType.Structured);
          p.Direction = ParameterDirection.Input;
          p.TypeName = "BigIntKeySQLVariantValueType";
          p.Value = numberList;
  </code></pre>