title: Chaining Lambda expressions
body: <p>I am trying to create code that will filter entity framework queries that is reusable and readable. The code I have below works except when I want to join two filters, as attempted in the commented out sections. Is anyone able to give direction and guidance on how to make this work?</p>
  
  <p>Below is the compile time error message that vs2012 displays when the line     </p>
  
  <pre><code>//IList&lt;Department&gt; departments3 = context.Set&lt;Department&gt;().Where(isHumanResourcesDepartment || isAccountsDepartment).ToList(); is uncommented
  </code></pre>
  
  <blockquote>
    <p>Operator '||' cannot be applied to operands of type
    'System.Func &lt; EfGenericRepositoryPoc.DataModel.Department,bool >' and
    'System.Func &lt; EfGenericRepositoryPoc.DataModel.Department,bool >'</p>
  </blockquote>
  
  <pre><code>    private static void TestCodeReadability2()
      {
  
          EmployeeDepartmentsConnection context = new EmployeeDepartmentsConnection();
  
          IList&lt;Department&gt; departments = context.Set&lt;Department&gt;().Where(isAccountsDepartment).ToList();
          IList&lt;Department&gt; departments2 = context.Set&lt;Department&gt;().Where(isHumanResourcesDepartment).ToList();
  
          //IList&lt;Department&gt; departments3 = context.Set&lt;Department&gt;().Where(isHumanResourcesDepartment || isAccountsDepartment).ToList();
  
      }
  
  
      private static Func&lt;Department, bool&gt; isAccountsDepartment = d=&gt;d.Name.ToLower().Contains("accounts");
      private static Func&lt;Department, bool&gt; isHumanResourcesDepartment = d=&gt;d.Name.ToLower().Contains("human resources");
  </code></pre>