Contains extension method on arrays is resolved from MemoryExtensions instead of Linq breaking EF queries #109869
Labels
needs-area-label
An area label is needed to ensure this gets routed to the appropriate area owners
Description
When using the .Contains extension method on an array inside an EF query, it uses the method .Contains from System MemoryExtensions instead of the System.Linq one breaking the query.
It throws "An exception was thrown while attempting to evaluate the LINQ query parameter expression"
Disabling LangVersion preview "fixes" the issue.
Reproduction Steps
I've attached a simple repro app ConsoleApp2.zip
Expected behavior
The .Contains method should be resolved to System.Linq or it should be accepted by EF so that the query can be translated to sql.
Actual behavior
The .Contains method is resolved from System MemoryExtensions that works on Spans making it not supported as a query
Regression?
I think this is a regression because if I use LangVersion Latest it starts working
Known Workarounds
Use a List instead of an array or simply use LangVersion Latest instead of Preview.
Configuration
Other information
I think the issue is cause by the OverloadResolutionPriority set to -1 in the MemoryExtensions .Contains method
The text was updated successfully, but these errors were encountered: