FirebirdSQL / NETProvider

Firebird ADO.NET Data Provider
https://firebirdsql.org/en/net-provider/
Other
161 stars 66 forks source link

EFCore generates query with OUTER APPLY instead of LEFT OUTER JOIN #1165

Closed MatejSpin closed 8 months ago

MatejSpin commented 8 months ago

Using: NET 8, Entity Framework Core 10.0.0 , Microsoft.EntityFrameworkCore 7.0.17 Server: Firebird 3.

We are migrating our NET 4.8 solution to NET 8. Updated EF providers to EF Core. A lot of queries are now coming up with following exception:

"Dynamic SQL Error\r\nSQL error code = -104\r\nToken unknown - line 3, column 1\r\nOUTER"

It's a pretty basic query:

var items= dbContext.Items.Where(x => relatedItemIds.Contains(x.RelatedItemId).Select(c => new { c.Id, c.State, c.ModifiedBy c.ModifiedDate, SubItems = c.SubItems.Select(y => new SubItemData() { y.ID, y.State, y.ModifiedBy, y.ModifiedDate, }) }).ToList();

This generates a working query with LEFT OUTER JOIN on .NET provider, but uses OUTER APPLY on the new NET Core provider - which Firebird does not support.

cincuranet commented 8 months ago

Correct. Firebird does not support CROSS/OUTER APPLY at the moment. The "shape" of query is generated by EF, provider is not doing that. So your quickest option is to rewrite your query. You can also contribute either to EF Core or Firebird and implement the respective feature or optimization.