Skip to content

[9.0] Fix collection conversion with nullable element converters (#3965) - #3968

Merged
roji merged 1 commit into
hotfix/9.0.5from
roji-nullable-converter-backport-9-0
Oct 15, 2026
Merged

roji merged 1 commit into
hotfix/9.0.5from
roji-nullable-converter-backport-9-0

Conversation

@roji

@roji roji commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Backport of #3965 (d33cdd4) to hotfix/9.0.5, addressing the converter failure reported in #3919.

Adapt the element conversion lambda's input and output nullability to the collection element types while preserving existing null guards. Include the original array/list round-trip regression tests.

The inherited nullable-comparer query test from the original PR does not exist in EF Core 9, so that inapplicable override is omitted. No other release-specific code adaptations.

Validation: both new regression tests failed before the fix; all 6 converter unit tests and 54 focused array/list conversion and primitive-collection Contains functional tests passed afterward using .NET SDK 9.0.312 and local PostgreSQL.

Limitation: The exact #3919 query (int[] parameter with numbers.Contains(x.Num.Value) and the nullable int?-to-string converter) still fails during ToQueryString() on 9.0 after this fix. It gets past element conversion, then hits a separate collection-comparer InvalidOperationException: EF cannot coerce ValueComparer<int?> to ValueComparer<int> while constructing ListOfValueTypesComparer. This backport leaves that separate issue unchanged.

Backport d33cdd4 to hotfix/9.0.5. Adapt element conversion input and output nullability while preserving existing null guards, with array/list round-trip coverage.

The inherited nullable-comparer functional test from the original change is not available on this release branch.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: b08c8c16-d069-4af1-a1b5-735487e9680b
@roji
roji merged commit 4acb06f into hotfix/9.0.5 Oct 15, 2026
10 checks passed
@roji
roji deleted the roji-nullable-converter-backport-9-0 branch October 15, 2026 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TargetInvocationException when using Contains with non nullable value types with HasConversion

1 participant