Skip to content

Using new[] in select query gives exception .NET 8 #32331

@Ogglas

Description

@Ogglas

File a bug

Include your code

I could not find anything about this and therefore decided to post this.

This code worked with .NET 7 and Microsoft.EntityFrameworkCore.SqlServer Version 7.0.13:

Updated = p.ThreatAndCountermeasures.Count() > 0 ? new[] { p.Updated, p.ThreatAndCountermeasures.Max(tac => tac.Updated) }.Max() : p.Updated,

With .NET 8 and Microsoft.EntityFrameworkCore.SqlServer Version 8.0.0 I get the following exception:

Query root of type 'InlineQueryRootExpression' wasn't handled by provider code. This issue happens when using a provider specific method on a different provider where it is not supported.

If I use this code it works:

Updated = p.ThreatAndCountermeasures.Count() > 0 ? new List<DateTime> { p.Updated, p.ThreatAndCountermeasures.Max(tac => tac.Updated) }.Max() : p.Updated,

https://learn.microsoft.com/en-us/ef/core/what-is-new/ef-core-8.0/breaking-changes

Include provider and version information

EF Core version: 8.0.0
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: NET 8.0
Operating system: Windows 11 Pro OS build 22621.2506
IDE: Microsoft Visual Studio 2022 (64-bit) - Current Version 17.8.0

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions