0

How to aggregate two expressions in C#? For example:

public virtual List<T> List(Expression<Func<T, bool>> filters, bool includeHistory = false, params Expression<Func<T, object>>[] include)
{
    // HOW TO DO THIS?
    filters = includeHistory ? filters : filters.Add(e=>e.DeleteDate == null);    
    List<T> entities = _baseDao.List<T>(filters, sorting, include)                   
}
Yuriy Mayorov
  • 961
  • 4
  • 15
  • 32

2 Answers2

0

Joe Albahari (Author of C# 3.0 in a Nutshell and LINQPad) wrote a utility called PredicateBuilder which can be used to AND and OR functions together.

http://www.albahari.com/nutshell/predicatebuilder.aspx

While it works on functions it is open source so you can check it out and see how it works.

0

I found solution here

Very good extension method to Expression class

Community
  • 1
  • 1
Yuriy Mayorov
  • 961
  • 4
  • 15
  • 32