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

Unnecessary null check for StartsWith #25010

Closed
roji opened this issue Jun 1, 2021 · 3 comments
Closed

Unnecessary null check for StartsWith #25010

roji opened this issue Jun 1, 2021 · 3 comments

Comments

@roji
Copy link
Member

roji commented Jun 1, 2021

_ = await ctx.Blogs
    .Where(b => b.Name.StartsWith("hello"))
    .ToListAsync();

SQL:

SELECT [b].[id], [b].[name]
FROM [blogs] AS [b]
WHERE [b].[name] IS NOT NULL AND ([b].[name] LIKE N'hello%')

/cc @maumar

@roji roji changed the title Unnecessary null check for LIKE Unnecessary null check for StartsWith Jun 1, 2021
@roji
Copy link
Member Author

roji commented Jun 1, 2021

Ah, seems like that bit in QueryOptimizingExpressionVisitor I always forget (and complain) about.

@ajcvickers ajcvickers added this to the Backlog milestone Jun 1, 2021
@ranma42
Copy link
Contributor

ranma42 commented Jun 23, 2024

Currently EFCore emits

SELECT [b].[BlogId], [b].[Name]
FROM [Blogs] AS [b]
WHERE [b].[Name] LIKE N'hello%'

as it should :)

@roji
Copy link
Member Author

roji commented Jun 23, 2024

Thanks @ranma42! Done as part of #31482

@roji roji closed this as completed Jun 23, 2024
@roji roji modified the milestones: Backlog, 8.0.0 Jun 23, 2024
@roji roji assigned roji and unassigned maumar Jun 23, 2024
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

4 participants