title: How to perform LINQ where clause inside a method
body: <p>I would like to perform LINQ <strong>where</strong> clause inside a method.</p>
  
  <p>For example:</p>
  
  <pre><code>using (BP_TTOKEntities db = new BP_TTOKEntities(_dto.IdTenant))
  {
      var res = db.doc003fornitura
  
      if (fornitura.Numero != null) //Filtro numero
      {
          if (!fornitura.Numero.LBoundIsNull) res = res.Where(x =&gt; x.fornitura_nro &gt;= fornitura.Numero.LBound);
          if (!fornitura.Numero.UBoundIsNull) res = res.Where(x =&gt; x.fornitura_nro &lt;= fornitura.Numero.UBound);
      }
  }
  </code></pre>
  
  <p>I would replace:</p>
  
  <pre><code>if (!fornitura.Numero.LBoundIsNull) res = res.Where(x =&gt; x.fornitura_nro &gt;= fornitura.Numero.LBound);
  if (!fornitura.Numero.UBoundIsNull) res = res.Where(x =&gt; x.fornitura_nro &lt;= fornitura.Numero.UBound);
  </code></pre>
  
  <p>with something like this:</p>
  
  <pre><code>res = fornitura.Numero.Where&lt;doc003fornitura&gt;(x.fornitura_nro);
  </code></pre>
  
  <p>Is it possible? How can I make the method?</p>
  
  <p>Thanks Luigi.</p>