Where clause using List.Contains with one elements results in = instead of IN
I create my query like this:
var search = new List<string> { "SUN" };
return query.Where(e => search.Contains(e.Company));
The SQL output is this:
WHERE [c].[Company] = N'sun'
If I add a second value to the list the = becomes IN:
var search = new List<string> { "SUN", "TEST" };
return query.Where(e => search.Contains(e.Company));
The SQL output is this:
WHERE [c].[Company] IN (N'sun', N'TEST')
I would expect a 'Contains' to always using IN in the above scenarios.
Include provider and version information
EF Core version: 6.0.3 Database provider: Microsoft.EntityFrameworkCore.SqlServer Target framework: NET 6.0 Operating system: Windows 11 Enterprise IDE: Visual Studio 2022 17.1.2
I just realized that with only one element in the list that's correct.