Closed Bouke closed 1 year ago
And that's where PredicateBuilder
comes in:
var conditions = new Expression<Func<string, bool>>[] {
a => a == "foo",
b => b == "bar",
c => c == "baz",
};
conditions.AggregateBalanced(PredicateBuilder.Or);
First of all, thank you for this great library. I've been able to rip out quite some (buggy) custom expression builders and replace it with this library. A big help.
I have a list of conditions (
Expression<Func<Type, bool>>
) that I want to pass to anIQueryable
. The number of conditions can be rather large, so I have to resort toAggregateBalanced
to prevent aStackOverflowException
. However the signatures ofAggregateBalanced
require anoperationToDo
ofTExpression
, in this case:Expression<Func<Type, bool>>
. I'd like to passExpression.Or
, but it isn't the proper type:I think with some reflection and/or casting I can probably get this working, but I feel this is a pretty common use-case for
AggregateBalanced
that would be beneficial to more users.Example (not working):
Additionally; instead of taking an array, consider accepting an
ICollection<>
so that users can pass in aList<>
as well.