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

Is it possible to query where string[] intersects string[]? #379

Open
VagyokC4 opened this issue May 11, 2023 · 2 comments
Open

Is it possible to query where string[] intersects string[]? #379

VagyokC4 opened this issue May 11, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@VagyokC4
Copy link

Hi @slorello89,

I'm trying to query using contains and filter by an array of values.

Finding the needle works as expected

var needle = "John";
collection.Where( x => x.Names.Contains(needle) ).ToListAsync();

How do I find multiple needles?

var needles = new[]{"John","Steve"};
collection.Where( x => x.Names.Any( y => needles.Contains(y)) ).ToListAsync();

Basically I want to find records where the two array values intersect.

But I get the following error: Unable to cast object of type 'System.Linq.Expressions.InstanceMethodCallExpression1' to type 'System.Linq.Expressions.BinaryExpression'.

Thoughts?

@slorello89
Copy link
Member

Not a case I thought of when I was implementing the Any behavior in last summer, but seems like something that should be doable.

@slorello89 slorello89 added the enhancement New feature or request label May 17, 2023
@VagyokC4
Copy link
Author

VagyokC4 commented Oct 7, 2023

Hello @slorello89, I trust you've been well. I hope everything is progressing smoothly on your end.

I was wondering if there have been any developments regarding this Any behavior issue? I've been encountering this use case increasingly.

Regarding this issue: #181 (comment), I am hopeful that we can target IEnumerable to encompass all .NET array-like structures.

Thank you once again for your attention to these matters.

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

No branches or pull requests

2 participants