title: Using Dynamic Or Expressions in C#
body: <p>I use the dynamic filter in my program like following solution:</p>
  
  <pre><code>public static IQueryable&lt;T&gt; MyFilter&lt;T&gt;(this IQueryable&lt;T&gt; queryable) where T : class ,IModel
  {
          var someIds = new int[]{1,2,3,4,5};
          var userId = 2;
  
          Expression&lt;Func&lt;T, bool&gt;&gt; predicate1 = e =&gt; someIds.Contains(e.Id);
          Expression&lt;Func&lt;T, bool&gt;&gt; predicate2 = e =&gt; e.UserId==userId;
          Expression&lt;Func&lt;T, bool&gt;&gt; predicate3 = e =&gt; e.CreatedDate != null;
  
          var pred1 = Expression.Lambda&lt;Func&lt;T, bool&gt;&gt;(System.Linq.Expressions.Expression.Or(predicate1, predicate2));
          var pred2 = Expression.Lambda&lt;Func&lt;T, bool&gt;&gt;(System.Linq.Expressions.Expression.Or(pred1, predicate3));
  
  
          var result = queryable
              .Where(pred2);
  
          return result;
      }
  </code></pre>
  
  <p>The <code>IModel</code> is like this:</p>
  
  <pre><code>Public interface IModel{
     int Id { get; set; }
     int UserId { get; set; }
     DateTime? CreatedDate { get; set; }
  }
  </code></pre>
  
  <p>but, I get this error:</p>
  
  <blockquote>
    <p>The binary operator Or is not defined for the types 'System.Func<code>2[AnyClass,System.Boolean]' and 'System.Func</code>2[AnyClass,System.Boolean]'.</p>
  </blockquote>
  
  <p>at this line:</p>
  
  <pre><code>var pred1 = Expression.Lambda&lt;Func&lt;T, bool&gt;&gt;(System.Linq.Expressions.Expression.Or(predicate1, predicate2));
  </code></pre>
  
  <p>How can I solve this problem?</p>
  
  <p>beforehand appreciate any help</p>