title: Filtering Linq query depending on some parameters
body: <p>I have the follwoing method to return some data for me:</p>
  
  <pre><code>public List&lt;Document&gt; GetDocumentsList(Guid sessionID, bool includeValid, bool includeExpired, bool includeAboutToExpire)
  {
     using (DB db = new DB())
     {
         // get the active documents
         var docs = db.Documents
                    .Where(d =&gt;
                        db.EmployeeStatuses
                       .Any(s =&gt; s.EmpID == d.EmpID &amp;&amp; s.StatusEndDate == null &amp;&amp; s.Status == "Active")
                          );
  
          // how to filter the result depending on includeValid, includeExpired and includeAboutToExpired parameters?
  
          return docs.ToList()
      }
  }
  </code></pre>
  
  <p>The problem here is, I want to filter the result depending on the <code>bool</code> parametes, for example if <code>includeValid</code> is true, then the valid documents will be included, if the <code>includeExpired</code> is true then the expired documents will be included and so on, I could have all three true or one or two of them are true. I do not want to have more than one call to the DB. Is there a logic that can do this with one call?</p>