Skip to content
This repository was archived by the owner on Jul 1, 2025. It is now read-only.

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant