title: WHERE IN Raw SQL Query used with ExecuteSqlCommand not working for multiple records
body: <p>I'm trying to make efficient use of a <code>UPDATE</code> query while updating multiple records (instead of looping for every <code>Id</code>). </p>
  
  <p>I have this simple method:</p>
  
  <pre><code>    public static async Task EfficientlyUpdateSentTimeforSomeTicketsAsync(List&lt;int&gt; Ids)
      {
          var parameters = Ids.Select((id, index) =&gt; new SqlParameter(string.Format("@p{0}", index), id));
          var parameterNames = string.Join(", ", parameters.Select(p =&gt; p.ParameterName));
          var query = string.Format("Update [TicketQueueTable] Set SentDatetime = {1} WHERE TicketQueueID IN ({0})", parameterNames, DateTime.Now);
  
          try
          {
              using (var db = GetDbContext())
              {
                  var affectedRows = await db.Database.ExecuteSqlCommandAsync(query, parameters.ToArray());
              }
          }
          catch (Exception ex)
          {
              await LogErrorAsync(ex);
              throw ex;
          }
      }
  </code></pre>
  
  <p>I took help from this SO question: <a href="https://stackoverflow.com/a/43969812/8644294">https://stackoverflow.com/a/43969812/8644294</a> but I'm unable to make this work. It hits me with exception that says: </p>
  
  <blockquote>
    <p>Incorrect syntax near '2'</p>
  </blockquote>
  
  <p>For simplicity, the Ids that I'm sending for now is <code>new List&lt;int&gt;() { 1, 2 }</code>.</p>
  
  <p>Thank you for your time.</p>