Skip to content

Conversation

@ahazelwood
Copy link

Fix NotSupportedException with empty inline arrays in Contains expressions

  • Add handling for op_Implicit and op_Explicit conversion operators
  • Optimize VisitStaticArrayMethodCall for pre-evaluated collections
  • Generate 'WHERE 1 = 0' for empty array Contains queries
  • Maintain C# 7.3 compatibility for .NET Standard 2.0 support
  • Add test coverage for inline empty array literals

Fixes issue where queries like .Where(x => new int[] {}.Contains(x.UserId))
would throw NotSupportedException during dynamic invocation of conversion
operators. Now properly evaluates the operand and generates valid SQL.

mikkelbu and others added 3 commits December 8, 2025 11:41
That does not depend on `System.Linq.Async`

Needed to make type explicit in `QueryWithProjectionAndEnclosedMethod1`.
Otherwise, we would get an `CS9226` as the new compiler would prefer
another overload - see e.g.
https://learn.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/9.0/params-overloads
…sions

- Add handling for op_Implicit and op_Explicit conversion operators
- Optimize VisitStaticArrayMethodCall for pre-evaluated collections
- Generate 'WHERE 1 = 0' for empty array Contains queries
- Maintain C# 7.3 compatibility for .NET Standard 2.0 support
- Add test coverage for inline empty array literals

Fixes issue where queries like .Where(x => new int[] {}.Contains(x.UserId))
would throw NotSupportedException during dynamic invocation of conversion
operators. Now properly evaluates the operand and generates valid SQL.
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.

2 participants