Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowing ToExpression to be overwritable, #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Allowing ToExpression to be overwritable, #16

wants to merge 1 commit into from

Conversation

hmadrigal
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant