title: Insert multiple entries in parameterized query
body: <p>I'm trying to do a multiple insert query using a parameterized command but I am getting a syntax exception thrown. The query in sql would look like:</p>
  
  <pre><code>CREATE TEMPORARY TABLE IF NOT EXISTS TEMP_PTO ( 
      ng_id INT, 
      requested_hours DECIMAL(7,4)
  );
  
  INSERT INTO TEMP_PTO VALUES
  (1, 0.0000), (2, 1.5000);
  </code></pre>
  
  <p>I generate it in C# via the following where <code>ptoHours</code> is an <code>IEnumerable</code> of a class containing the <code>ng_id</code> and the <code>requested_hours</code>. <code>Queries</code> is an <code>resx</code> file containing the query text, and <code>Queries.PTOLoadTempCommand</code> = <code>INSERT INTO TEMP_PTO VALUES @v;</code>:</p>
  
  <pre><code>        using (var conn = new MySqlConnection(this.connString))
          {
              MySqlTransaction trans = null;
              try
              {
                  await conn.OpenAsync();
                  trans = conn.BeginTransaction();
  
                  using (var tempCommand = conn.CreateCommand())
                  {
                      tempCommand.CommandText = Queries.PTOTempTableCommand;
                      await tempCommand.ExecuteNonQueryAsync();
                  }
  
                  using (var loadCommand = conn.CreateCommand())
                  {
                      loadCommand.CommandText = Queries.PTOLoadTempCommand; //INSERT INTO TEMP_PTO VALUES @v;
                      loadCommand.Parameters.AddWithValue("@v", String.Join(", " ,ptoHours.Select(p =&gt; String.Format("({0}, {1:N4})", p.AgentId, p.UsedVacationHours))));
                      //Exception thrown here
                      var affected = await loadCommand.ExecuteNonQueryAsync();
                      if (affected != entryCount)
                          throw new Exception("Not All Entries Loaded");
                  }
  
                  trans.Commit();
              }
              catch (Exception e)
              {
                  if(trans!= null) trans.Rollback();
              }
          }
  </code></pre>
  
  <p>Looking at the <code>loadCommand</code> object, I can see that the value of the parameter <code>@v</code> is <code>(1, 0.0000), (2, 1.5000)</code>. Are you able to do an insert like this or do I need to modify the function to insert them one at a time? I know I could go the <code>StringBuilder</code> route, but then I cannot use the safety of the parameterization.</p>