Add AnyOf to TableQuery to build more complex OR clauses. #168
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We have a filter interface, where our users can specify predicates to filter a large set of data. Some of these predicates should be ANDed, and some of these should be ORed. For AND, predicates can easily be added on top of each other by chaining
Where
calls, but there's no way to build an OR clause with an a priori unknown number of predicates, since the only way to specify an OR clause is||
and SQLite.Net expects a pretty basic expression.The new
AnyOf
method takes a (params-)array of predicates, which allows us to makeWHERE ... OR ...
queries from lists of predicates, like so:AnyOf
looks even nicer like so, although in this case we could also useWhere
and||
:Note that this is my first foray into extending SQLite.Net, so cut me a little slack, but feel free to criticize the code to the fullest extent :)