title: LINQ to SQL Where Clause Optional Criteria
body: <p>I am working with a LINQ to SQL query and have run into an issue where I have 4 optional fields to filter the data result on.  By optional, I mean has the choice to enter a value or not.  Specifically, a few text boxes that could have a value or have an empty string and a few drop down lists that could have had a value selected or maybe not...</p>
  
  <p>For example:</p>
  
  <pre><code>    using (TagsModelDataContext db = new TagsModelDataContext())
       {
          var query = from tags in db.TagsHeaders
                      where tags.CST.Equals(this.SelectedCust.CustCode.ToUpper()) 
                      &amp;&amp; Utility.GetDate(DateTime.Parse(this.txtOrderDateFrom.Text)) &lt;= tags.ORDDTE
                      &amp;&amp; Utility.GetDate(DateTime.Parse(this.txtOrderDateTo.Text)) &gt;= tags.ORDDTE
                      select tags;
          this.Results = query.ToADOTable(rec =&gt; new object[] { query });
      }
  </code></pre>
  
  <p>Now I need to add the following fields/filters, but only if they are supplied by the user.</p>
  
  <ol>
  <li>Product Number - Comes from another table that can be joined to TagsHeaders.</li>
  <li>PO Number - a field within the TagsHeaders table.</li>
  <li>Order Number - Similar to PO #, just different column.</li>
  <li>Product Status - If the user selected this from a drop down, need to apply selected value here.</li>
  </ol>
  
  <p>The query I already have is working great, but to complete the function, need to be able to add these 4 other items in the where clause, just don't know how!</p>