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

string.Compare not supported with LINQ to SQL #2598

Closed
jkendle opened this issue Jul 7, 2021 · 3 comments · Fixed by #3668
Closed

string.Compare not supported with LINQ to SQL #2598

jkendle opened this issue Jul 7, 2021 · 3 comments · Fixed by #3668
Labels
feature-request New feature or request LINQ QUERY

Comments

@jkendle
Copy link

jkendle commented Jul 7, 2021

Describe the bug

ExpressionToSQL::VisitBinary does not support string.Compare, only CompareTo

We're using the Microsoft.OData.Core nuget package to project OData queries into CosmosDB.

The Microsoft.OData.Core nuget package generates expressions with string.Compare

To Reproduce

We can reproduce without the OData dependency.

We have an IQueryable that fails with a Where clause like this:

.Where(m => string.Compare(m.Id, "hello") == 0)

However, it works if we do:

.Where(m => m.Id.CompareTo("hello") == 0);

Expected behavior

The SDK should generate valid SQL similar to

Id = "hello"

Actual behavior

The SDK throws an exception of type DocumentQueryException with the message "Method 'Compare' is not supported."

Environment summary
SDK Version: 3.20.1
OS Version (e.g. Windows, Linux, MacOSX): MacOS, Linux

Additional context

@j82w j82w added feature-request New feature or request LINQ labels Jul 7, 2021
@kylemc
Copy link

kylemc commented Jul 8, 2021

@j82w we patched this feature on a fork and would love to commit it back to the main line. Let us know how best we can engage.

@j82w
Copy link
Contributor

j82w commented Jul 8, 2021

@kylemc is there anything blocking you from sending a PR? You should be able to create a PR from the fork.

@petrv7
Copy link

petrv7 commented Jul 26, 2021

@kylemc Any updates? I'm having the same problem while using

_container.GetItemLinqQueryable<SomeEntity>().Where(x => string.Compare(x.Id, "something", StringComparison.Ordinal) == 0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request LINQ QUERY
Projects
None yet
5 participants