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

New case sensitive on preview does not work with EF #203

Closed
moxplod opened this issue Aug 18, 2024 · 5 comments
Closed

New case sensitive on preview does not work with EF #203

moxplod opened this issue Aug 18, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@moxplod
Copy link
Contributor

moxplod commented Aug 18, 2024

Version

2.15.0-preview6

Details

I pulled the preview version into my solution and ran my tests. The new case insensitive linq statements do not work with entity framework.

Related changes: #194

I have these global configurations in my project -

    GridifyGlobalConfiguration.EnableEntityFrameworkCompatibilityLayer();
    GridifyGlobalConfiguration.CaseInsensitiveFiltering = true;
    GridifyGlobalConfiguration.DefaultDateTimeKind = DateTimeKind.Utc;

Here is an example error -

System.InvalidOperationException
The LINQ expression 'DbSet()
.Where(t => t.AccountId == __ef_filter__accountId_0)
.Where(t => t.Name.Contains(
value: __Value_0,
comparisonType: InvariantCultureIgnoreCase))' could not be translated. Additional information: Translation of method 'string.Contains' failed. If this method can be mapped to your custom function, see https://go.microsoft.com/fwlink/?linkid=2132413 for more information. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.

Another -

The LINQ expression 'DbSet()
.Where(t => t.AccountId == __ef_filter__accountId_0)
.Where(t => string.Equals(
a: t.Name,
b: __Value_0,
comparisonType: InvariantCultureIgnoreCase))' could not be translated. Additional information: Translation of the 'string.Equals' overload with a 'StringComparison' parameter is not supported.

Steps to reproduce

Provided above.

@moxplod moxplod added the bug Something isn't working label Aug 18, 2024
@moxplod
Copy link
Contributor Author

moxplod commented Aug 18, 2024

I read more about this and looks like String.Equals(String, StringComparison) is not supported in ef core. For any SQL databases, SQL server or PostgreSQL. Here is a detailed discussion.

@moxplod
Copy link
Contributor Author

moxplod commented Aug 18, 2024

@alirezanet FYI - dotnet/efcore#1222

@alirezanet
Copy link
Owner

alirezanet commented Aug 18, 2024

Hi @moxplod,
I didn't expect this 🙁, so I think for now the best solution is reverting PR #194 and keeping the old code with ToLower() method.

@moxplod
Copy link
Contributor Author

moxplod commented Aug 18, 2024

Yea - I think that is the best way forward. I have it working locally (with a DLL for now) with the code changes that I had done. From that PR - just keep my commits as they are with the use of the new configuration and ToLower () methods.

Sorry about this, I also when I read the PR didn't associate that String.Equal with StringComparison is not translatable by EF. We should probably have some integration test that help us with this in the library for the future.

@moxplod
Copy link
Contributor Author

moxplod commented Aug 20, 2024

@alirezanet I had some time - did the git revert of the changes. Do take a look - #205

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants