Is there is a way to shortcut this code
Expression<Func<MyType, bool>> a => t => ...;
Expression<Func<MyType, bool>> b => t => ...;
Expression<Func<MyType, bool>> c => t => ...;
await myIQueryableOfMyType
.Where(a)
.Where(b)
.Where(c)
.ToArrayAsync()
in a way that I have had a single Experssion withing a Single Where clause. My purpose is to replace the "a", "b", "c" expressions to variable set of conditions.
I have tried to aggregate a function and set it in the new Lambda Expression
Expression<Func<MyType, bool>>[] predicates = ...
Func<MyType, bool> func = t => predicates == null || predicates.Aggregate(true, (prev, current) => prev && current.Compile()(t));
but it does not work for IQueryable collections of Entity Framework