Repository navigation
Preserve implicit conversions during query precompilation - #39313
AndriySvyryd with Copilot wants to merge 6 commits into
Conversation
…xpressions Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
Agent harness evaluation deferredThis PR affects: |
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
There was a problem hiding this comment.
🔵 Needs a closer look
Binary conversion handling affects multiple operators, and Roslyn and provider regression tests were not executed during this review.
No open issues 🎉
What changed in this PR
Fixes query precompilation failures by preserving implicit conversions when reconstructing expression trees.
Changes:
- Applies semantic conversions to conditional branches and binary operands while preserving reference equality and
is/ashandling. - Adds conversion-focused unit tests and a shared precompiled-query regression with SQL Server assertions.
- Documents the conversion requirement in query-pipeline guidance.
| File | Description |
|---|---|
| test/EFCore.SqlServer.FunctionalTests/Query/AdHocPrecompiledQuerySqlServerTest.cs | Adds SQL baseline for the regression. |
| test/EFCore.Relational.Specification.Tests/Query/AdHocPrecompiledQueryRelationalTestBase.cs | Adds shared generation, compilation, and execution coverage. |
| test/EFCore.Design.Tests/Query/CSharpToLinqTranslatorTest.cs | Tests nullable, numeric, and user-defined conversions. |
| src/EFCore.Design/Query/Internal/CSharpToLinqTranslator.cs | Preserves semantic operand and branch conversions. |
| .agents/skills/query-pipeline/SKILL.md | Documents expression reconstruction requirements. |
Review effort: Balanced
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. Updated |
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>


Query precompilation drops implicit conversions when reconstructing conditional branches and binary operands. This causes valid C# projections with nullable results—and equality comparisons requiring user-defined conversions—to fail during expression-tree construction.
Translation
ConvertedTypebefore constructing conditional and binary nodes.is/ashandling.Coverage
Nullable constructor arguments no longer require an explicit cast on the non-null branch: