Skip to content

.NET 10 + C# 14: Entity queries using Contains may not work #560

@Daniel-Svensson

Description

@Daniel-Svensson

C# 14 changes the rules for method selection so that ReadOnlySpan extensions are preferred over corresponding Linq methods.

This can cause existing code that works to fail when compiling with C#14 and .NET10+ (.NET8 seems to not be effected).

Not working:

int[] prodIds = [ 1, 2, 3, 4, 5 ];
EntityQuery<Product> query = catalog.GetProductsQuery().Where(p => prodIds.Contains(p.ProductID));

Working:

IEnumerable<int> prodIds = [ 1, 2, 3, 4, 5 ];
EntityQuery<Product> query = catalog.GetProductsQuery().Where(p => prodIds.Contains(p.ProductID));

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions