When targeting .NET 10 (with C# 14), the compiler overload resolution rules changed (other docs), which breaks some usage of Contains and friends.
Example issue
Given the code:
string[] names = ["a", "b", "c"];
connection.Table<MyType>.Where(t => names.Contains(t.Name))
the Contains previously would resolve to Enumerable.Contains(names, t.Name), which was handled here. However, in .NET 10 (actually, C# 14), the Contains resolves to MemoryExtensions.Contains((ReadOnlySpan<MyType>)names, t.Name).
This results in SQL generated like select * from \"MyType\" where (\"Name\" in op_implicit((?,?))), which results in an exception like SQLite.SQLiteException: no such table: op_implicit.
EF Core had to change to support this, too
See similar issues for Expression tree handling in EFCore:
Recommended solution
Update TableQuery<T>.CompileExpr to:
- Detect
MemoryExtensions.Contains (both the 2-argument and 3-argument versions if the 3rd argument is null), and treat it as though it were Enumerable.Contains, in particular unwrapping and ignoring the implicit cast.
- Consider whether to do the same for
MemoryExtensions.SequenceEqual.
When targeting .NET 10 (with C# 14), the compiler overload resolution rules changed (other docs), which breaks some usage of
Containsand friends.Example issue
Given the code:
the
Containspreviously would resolve toEnumerable.Contains(names, t.Name), which was handled here. However, in .NET 10 (actually, C# 14), theContainsresolves toMemoryExtensions.Contains((ReadOnlySpan<MyType>)names, t.Name).This results in SQL generated like
select * from \"MyType\" where (\"Name\" in op_implicit((?,?))), which results in an exception likeSQLite.SQLiteException: no such table: op_implicit.EF Core had to change to support this, too
See similar issues for
Expressiontree handling in EFCore:Containsbehaves differently for arrays of enums, for some reason.Recommended solution
Update
TableQuery<T>.CompileExprto:MemoryExtensions.Contains(both the 2-argument and 3-argument versions if the 3rd argument isnull), and treat it as though it wereEnumerable.Contains, in particular unwrapping and ignoring the implicit cast.MemoryExtensions.SequenceEqual.