You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that a static field fails while a local variable succeeds.
Steps to reproduce
Create DbContext using EF core 3.1
Declare static field "MyCollection" of type IReadOnlyCollection<> and assign values.
Use the field in linq query .Where(x => mycollection.Contains(x.Prop))
The LINQ expression 'DbSet<ExampleTable>
.Where(e => (IReadOnlyCollection<int>)ReadOnlyCollection<int> { 5, 6, 7, }
.Contains(e.MyProp))' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to either AsEnumerable(), AsAsyncEnumerable(), ToList(), or ToListAsync(). See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
EF Core version: 3.1
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET Core 3.1
Operating system: Windows x64
IReadOnlyCollection<>.Contains() cannot be translated to SQL by EF core 3.1
EF core 2.2 supports it
Related issue of ICollection<>: #17599
It seems that a static field fails while a local variable succeeds.
Steps to reproduce
Create DbContext using EF core 3.1
Declare static field "MyCollection" of type IReadOnlyCollection<> and assign values.
Use the field in linq query .Where(x => mycollection.Contains(x.Prop))
EF Core version: 3.1
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET Core 3.1
Operating system: Windows x64
Remark this works (as local variable):
It also works if the type of the static field is changed to List
The text was updated successfully, but these errors were encountered: