title: Appending a list of integers to your SQL Server query in c#. How can I do this?
body: <p>Here is a broken down version of my problem :</p>
  
  <p>I have a method. The argument is a list of integers. I wish to create an optimised SQL query that returns a particular value on all rows where the id of that row is equal to one of the integers in the argument list. Simple, right ?</p>
  
  <p>I have a feeling I have made it more difficult than it needs to be :</p>
  
  <pre><code>private List&lt;string&gt; ReturnValue(List&lt;int&gt; ids)
          {
              List&lt;string&gt; ValuesIWantToReturn = new List&lt;string&gt;();
              StringBuilder sb = new StringBuilder("SELECT ValueIWantToReturnfrom table WHERE ");
              foreach (int id in ids)
              {
                  sb.Append( string.Format("ID = {0} OR ", id) );
              }
              sb.Remove(sb.Length - 3, 3); //remove trailing "OR"
                             sb.Append(";");
              SqlDataReader reader =  RunSelectQuery( sb.ToString() );
              while (reader.Read())
              {
                  ValuesIWantToReturn.Add(reader.GetString(0));
              }
  
              return ValuesIWantToReturn;
          }
  </code></pre>
  
  <p>Any feedback on the general readability and structure of my code would be appreciated too. It's always nice to improve :)</p>