EF Core 8 Query Translation Bug: Array operations with union
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- PR merge metrics
- PR metrics pending
Description
### Description
After upgrading to EF8 from EF6, one of our complex queries including array operations stopped working ( everything worked fine with EF6 ).
After debugging, we narrowed the problem to array operation after using union or concat. ( writing the same query without using concat worked fine )
### Entity Framework Query
```C#
public enum SomeEnum
{
E1,
E2,
}
public class Obj1
{
public string Id { get; set; }
public SomeEnum[] Types { get; set; }
}
public class Obj2
{
public string Id { get; set; }
public SomeEnum[] Types { get; set; }
}
var queryable = context.objs1.Select(_ => new { _.Id, _.Types })
.Concat(context.objs2.Select(_ => new { _.Id, _.Types }))
.Where(_ => _.Types.Contains(SomeEnum.E1))
.ToList();
```
### Stack traces
```
.Contains(__p_2))' could not be translated. Additional information: Translation of method 'System.Linq.Enumerable.Contains' failed. If this method can be mapped to your custom function, see https://go.microsoft.com/fwlink/?linkid=2132413 for more information. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
```
EF Core version: 8.0.2
Database provider: Npgsql 8.0.2
Target framework: .NET 8.0
Contributor guide
Assessment
This issue has not been assessed yet.