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

odata startswith uri differs from odata standard and causes entity framework to generate suboptimal sql #236

Open
jgtestw opened this issue May 6, 2024 · 8 comments

Comments

@jgtestw
Copy link

jgtestw commented May 6, 2024

The code that converts a startswith predicate to an odata uri generates the following uri

startswith(mobile,'0430404111') eq true

instead of

startswith(mobile,'0430404111')

This causes the sql generated by entity framework to be suboptimal. Why do you tack eq true onto the end of the startswith? The odata standard does not require this. It also makes entity framework generate suboptimal sql:

((CASE WHEN ([Extent1].[Mobile] LIKE @p__linq__0 ESCAPE N''~'') THEN cast(1 as bit) WHEN ( NOT ([Extent1].[Mobile] LIKE @p__linq__0 ESCAPE N''~'')) THEN cast(0 as bit) END) = @p__linq__1)

instead of

[Extent1].[Mobile] LIKE @p__linq__0 ESCAPE N''~''

@steveschmitt
Copy link
Member

I don't know the answer why Breeze does that, but it may be that Entity Framework didn't work the same way back when Breeze was first tested. Frankly, I'm surprised that EF handles eq true so poorly. What version of EF are you using?

@jgtestw
Copy link
Author

jgtestw commented May 6, 2024

EF 6

@jgtestw
Copy link
Author

jgtestw commented May 14, 2024

@steveschmitt Can you foresee any problem with changing the code in our custom odata uri adapter to not add the eq true part to the end of startswith?

@steveschmitt
Copy link
Member

@jgtestw It is fine for you to change the code.

@jgtestw
Copy link
Author

jgtestw commented May 15, 2024

@steveschmitt Ok thanks

@jgtestw
Copy link
Author

jgtestw commented May 25, 2024

@steveschmitt Do you want me to update the actual breeze source code too? Submit a pull request?

@steveschmitt
Copy link
Member

Yes, please submit a pull request.

@jgtestw
Copy link
Author

jgtestw commented May 26, 2024

ok i will

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

No branches or pull requests

2 participants