Finally, I have found a way to avoid combining multiple predicates to the main expression tree.
Given that each predicate represents a different filter and I want the final, combined filter to be a series of must-be-respected conditions, we can say that each of the predicates has to return true for the final predicate to return true.
For that to work, the predicates has to be combined with AND
. So, the resulting SQL query must look like this :
predicate1 AND predicate2 AND predicate3
...
A better way to combine these predicates with AND
is to chain Where
query operators to the final query, like this :
var documents = this.ObjectSet.AsExpandable()
.Where(mainPredicate)
.Where(otherPredicate)
.Where(yetAnotherPredicate)
.ToList();
The resulting SQL query will combine each of these predicates with AND
. That is just what I wanted to do.
It is easier than hacking out an expression tree by myself.