I am using PredicateBuilder and Colin Meek's equivalent to compose predicates in an WCF Data Services friendly (i.e. no invocation expressions etc.) way. These work for some queries but fail with "Recursion reached allowed limit" as the query complexity increases. Unfortunately, this limit is below what I expect in normal circumstances in my code. I'm also unable to determine beforehand when this limit is reached.
Is is possible to:
- simplify predicates before they hit WCF Data Services?
- determine when query complexity exceeds the limit for WCF Data Services?
In my code, I'm building a predicate for Azure Data Market services that accept 'state' and 'city' parameters. Rather than issue a call for each city*state pairing, I'm composing a predicate along the lines of:
((city eq City11 or city eq City12 ...or city eq City1N) and (state eq State1))
...
or
((city eq CityM1...) and (state eq StateM))
Because of the expression tree, in actuality the predicate would be more like this:
((false or (((false or (City eq City11)) or (City eq City12)) and (State eq State1))) or (((false or (City eq City21)) or (City eq City22)) and (State eq State2)))
Using LINQPad I can capture the request, manually simplify it and prove that these work once simpified. Because no simpification is attempted by my code, the OData query that hits Azure Data Services is overly complex/recursive and generates the exception. In outline above, I apply the simplifications such as (x or y) or z == x or y or z and this has the effect of reducing the complexity of the query sufficiently that it passes muster. Hence my two questions above.
Any help/pointers would be very much appreciated!