title: Sql filter and or statement within C# application
body: <p>I have a C# application in which i have this problem : when i run this snippet:</p>
  
  <p><strong>First Way</strong></p>
  
  <pre><code>public void GetList(List&lt;string&gt; liste, List&lt;int&gt; outliste)
  {
      foreach( string s in liste){
          outliste.Add(SqlFunction(s));
      }
  }
  public int SqlFunction(string str)
  {
      string query = "select id from user where name="+str;
      ...................
      // return the id
  }
  </code></pre>
  
  <p>the execution time is 51 sec</p>
  
  <p><strong>Second Way</strong></p>
  
  <pre><code>public void SqlSecondWayFunction(List&lt;string&gt; liste, List&lt;int&gt; outliste)
  {
  
     string query ="select id from user where (";
     foreach(string str in liste){
         query += "name=" str + "or  ";
     }
     query += " 1=0 )";
  
     ...................
     // fill outliste by the result of the query
  }
  </code></pre>
  
  <p>The execution time is 1m:19sec!!!!!!!!! ( the count of the <code>liste</code> is about 11000).</p>
  
  <p>So i need to know why the first way is faster?</p>