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

Server Side Evaluation #20995

Closed
nimeshvaghasiya opened this issue May 20, 2020 · 3 comments
Closed

Server Side Evaluation #20995

nimeshvaghasiya opened this issue May 20, 2020 · 3 comments
Labels
closed-no-further-action The issue is closed and no further action is planned. customer-reported

Comments

@nimeshvaghasiya
Copy link

nimeshvaghasiya commented May 20, 2020

EF Core 3.1.x:

I would not like to load all products in memory, which below queries do!
Guess what happen if i do have millions of products in table?

var products = context.Products.ToList();
products = products.Where(p => p.Name.Contains("xxx")).ToList();

And below query throws
The LINQ expression 'DbSet-Product-
.Where(b => b.Name.Contains(
value: "xxx",
comparisonType: InvariantCultureIgnoreCase))' 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().

var products = context.Products.Where(p => p.Name.Contains("xxx", StringComparison.InvariantCultureIgnoreCase)).ToList();

Related Issue: #19087

Can anyone help me out. how to filter data with server side evaluation with ef core 3.1.x?

@roji
Copy link
Member

roji commented May 20, 2020

Duplicate of #1222

@roji roji marked this as a duplicate of #1222 May 20, 2020
@roji
Copy link
Member

roji commented May 20, 2020

EF Core does translate Contains for server-side evaluation - but not the overload that accepts StringComparison.InvariantCultureIgnoreCase (or any other StringComparison). In other words, your query above should be working as-is, can you please double-check that are you aren't getting the translation exception from another query which passes InvariantCultureIgnoreCase?

For more context on why we don't translate StringComparison, see #1222 (comment). EF Core 5.0 is bringing collation support which would allow you to do context-insensitive operations, but via other ways.

@nimeshvaghasiya
Copy link
Author

Thanks @roji

@roji roji added closed-no-further-action The issue is closed and no further action is planned. and removed type-enhancement labels May 20, 2020
@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
Labels
closed-no-further-action The issue is closed and no further action is planned. customer-reported
Projects
None yet
Development

No branches or pull requests

3 participants