Repository navigation
Preserve implicit conversions in precompiled equality expressions - #39482
Closed
AndriySvyryd with Copilot wants to merge 2 commits into
Closed
AndriySvyryd with Copilot wants to merge 2 commits into
AndriySvyryd with Copilot wants to merge 2 commits into
Conversation
Co-authored-by: AndriySvyryd <[email protected]>
Copilot
AI
changed the title
[WIP] Fix query precompilation error with convertible types
Preserve implicit conversions in precompiled equality expressions
Oct 30, 2026
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
A critical active finding indicates the inherited test will fail the SQL Server override guard before execution because its required provider override and SQL baseline are missing.
1 open issue
What changed in this PR
This pull request fixes precompiled-query translation for equality comparisons involving converter-backed custom properties and implicit conversions.
Changes:
- Preserve Roslyn’s converted operand types for
==and!=expressions. - Add relational regression coverage for a custom type implicitly convertible to
string. - Add supporting value-converter model and test data.
| File | Summary |
|---|---|
src/EFCore.Design/Query/Internal/CSharpToLinqTranslator.cs |
Preserves implicit operand conversions when translating equality and inequality expressions. |
test/EFCore.Relational.Specification.Tests/Query/AdHocPrecompiledQueryRelationalTestBase.cs |
Adds regression coverage for comparing a converter-backed custom property with a string parameter. The inherited test requires a corresponding SQL Server override and AssertSql baseline. |
Review effort: Lite
| } | ||
|
|
||
| [Fact] | ||
| public virtual async Task Compare_converted_property_to_string() |
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.

Precompiling a query that compares a converter-backed custom property with a
stringparameter failed because the generated expression tree retained mismatched operand types.==and!=, preserving C# implicit conversions.stringand mapped with a value converter.