Repository navigation
Support unqualified class constants in query precompilation - #39298
Merged
Merged
Conversation
Co-authored-by: AndriySvyryd <[email protected]>
Copilot
AI
changed the title
[WIP] Fix query precompiler rejecting class constant in predicate
Support unqualified class constants in query precompilation
Oct 16, 2026
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Constant translation must use Roslyn’s contextual converted type to support implicit conversions correctly.
No open issues 🎉
What changed in this PR
Adds support for unqualified class constants in query precompilation, including enums and typed nulls.
Changes:
- Translate constant fields into typed expression constants.
- Add translator regression tests.
- Add relational, SQLite, and SQL Server coverage with SQL baselines.
| File | Summary |
|---|---|
test/EFCore.SqlServer.FunctionalTests/Query/PrecompiledQuerySqlServerTest.cs |
Adds SQL Server query coverage and baseline. |
test/EFCore.Sqlite.FunctionalTests/Query/PrecompiledQuerySqliteTest.cs |
Adds SQLite query coverage and baseline. |
test/EFCore.Relational.Specification.Tests/Query/PrecompiledQueryRelationalTestBase.cs |
Adds shared precompilation regression coverage. |
test/EFCore.Design.Tests/Query/CSharpToLinqTranslatorTest.cs |
Tests primitive, enum, and null constants. |
src/EFCore.Design/Query/Internal/CSharpToLinqTranslator.cs |
Handles constant field symbols. |
Review effort: Lite
Code coverage overviewLanguages: C# C# / code-coverage
View coverage of the 10 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. |
AndriySvyryd
enabled auto-merge (squash)
October 31, 2026 00:27
cincuranet
approved these changes
Nov 4, 2026
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.
Query precompilation rejects unqualified class constants in predicates as unknown identifiers, even though equivalent literals and captured locals work.
This enables predicates such as: