Allowing ToExpression to be overwritable, #16
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.
Hi,
I am using the package https://www.nuget.org/packages/System.Linq.Dynamic.Library/ , in my approach for implementing some filter logic I'd like to support "in" operator. For example, the client sends a filter instance:
{ field:"CountryId", operator: "in", value:"[1,2,3]" }
The ToExpression method generates an invalid string for the Dynamic LINQ. Thus, I'd like to implement a subsclass which deals with this specific situation for me and it should be able to create something like:
"new List() {1,2,3}.Contains(CountryId)"
NOTE: Not sure if there is a better alternative other than creating the List as part of the Where clause.
Just in case, if the input were:
{ field:"CountryId", operator: "contains", value:"[1,2,3]" },
then the generated expression would be:
"CountryId.Contains([1,2,3])"
but this is incorrect because the goal is the check the the array contains the CountryId, not the other way around)
In any case, my idea with this change is like subclasses can add support to custom filter options, just by being able of overriding the ToExpression method.