title: Trim function within a Where Clause
body: <p>Say you have a Collection of items</p>
  
  <pre><code>    IList&lt;string&gt; items = List&lt;string&gt;();
  </code></pre>
  
  <p>And you want to search each element against some search term: <em>term</em>. If you performed a Trim() within the Where clause as follows, would the trim operation occur for each element in the sequence, or would it be compiled once and then used to check against the elements?</p>
  
  <pre><code>    items.Where(o =&gt; o.Contains(term.Trim())).ToList(); 
  </code></pre>
  
  <p>This question was based on a LINQ to SQL statement but I have simplified it. (Unsure if compiling to SQL would make any difference).</p>