Repository navigation
Fix precompiled queries not capturing parameter symbol - #39149
Merged
Merged
Conversation
Contributor
Author
|
@dotnet-policy-service agree |
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused implementation covers both missing symbol paths with end-to-end regression tests and matching SQL assertions.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes precompiled query discovery and translation for method parameters, including DbContext parameters and values captured by query lambdas.
Changes:
- Recognizes parameter symbols during query discovery and LINQ translation.
- Adds relational coverage and SQL Server baselines for both scenarios.
| File | Description |
|---|---|
src/EFCore.Design/Query/Internal/QueryLocator.cs |
Recognizes parameter-based DbContext query roots. |
src/EFCore.Design/Query/Internal/CSharpToLinqTranslator.cs |
Translates captured method parameters. |
test/EFCore.Relational.Specification.Tests/Query/PrecompiledQueryRelationalTestBase.cs |
Adds provider-independent regression tests. |
test/EFCore.SqlServer.FunctionalTests/Query/PrecompiledQuerySqlServerTest.cs |
Adds expected SQL baselines. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
AndriySvyryd
approved these changes
Oct 2, 2026
AndriySvyryd
left a comment
Member
There was a problem hiding this comment.
Thanks for your contribution!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The proposed changes solve the parameter capture issue (an IParameterSymbol case was missing) when trying to precompile queries.
This solves the following error:
when trying to compile:
due to parameters
parameterContextandidnot being recognized as valid captured symbols.I've added some unit tests to account for regular argument capturing and DbContext capturing from a parameter symbol.
Fixes #35887