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

How to get all strings that contains any of a given words? #19273

Closed
ComptonAlvaro opened this issue Dec 11, 2019 · 4 comments
Closed

How to get all strings that contains any of a given words? #19273

ComptonAlvaro opened this issue Dec 11, 2019 · 4 comments

Comments

@ComptonAlvaro
Copy link

ComptonAlvaro commented Dec 11, 2019

I am using EF Core 3.0.

I am trying to get all the rows that a property contains any of a list of strings. I am trying in this way:

string myWordsToSearch = "word1 word2 word3";
List<string> miLstWords = myWordsToSearch
    .Split(" ")
    .Where(x => string.IsNullOrWhiteSpace(x) == false)
    .ToList();
MyDbContext.MyDbSet.Where(x => miLstWords.Any(y => x.MyPropertyInDbSet.Contains(y)));

But I get this exception:

One or more errors occurred. (The LINQ expression 'Where( source: DbSet, predicate: (s) => Any( source: (Unhandled parameter: __miLstWords_0), predicate: (y) => MyPropertyInDbSet.Contains(y)))' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to either AsEnumerable(), AsAsyncEnumerable(), ToList(), or ToListAsync(). See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.

Thanks.

@ajcvickers
Copy link
Member

@ComptonAlvaro Please try EF Core 3.1. (This looks similar to issues that were fixed for 3.1, such as #17342)

@smitpatel
Copy link
Member

Duplicate of #19070

@ComptonAlvaro
Copy link
Author

I have tried with EF Core 3.1.0 and I still have the same problem.

@ajcvickers
Copy link
Member

@ComptonAlvaro #19070 is not fixed in 3.1--it's in the Backlog milestone. Are you saying that this is not a duplicate of #19070? If so, please post a small, runnable project that demonstrates what you are seeing so that we can understand the difference.

@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants