[Bug] EF Core InvalidOperationException on split query with FromSql join and collection Include
Los mantenedores suelen responder en 2 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 65/100
Línea de trabajo
Start from the provided EF Core query and reproduce the InvalidOperationException in a test or small console sample using EF Core 10.0.10. Trace the relational query translation for FromSql, Join, Include, and AsSplitQuery() through the relational query components. The work is done when the split query no longer throws for the collection include and returns the expected entities with ORDetails loaded.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Bug description
Bug Summary
An unhandled System.InvalidOperationException occurs in Entity Framework Core when querying OR with OR.ORDetails included (AsSplitQuery()) via a FromSql join on @orIds.
Steps to Reproduce / Context
- FE Screen / User Action:
[Insert FE screen or action that triggers this request] - API Endpoint:
[Insert endpoint, e.g., POST /api/...] - Request Payload / Parameters:
[Insert sample payload, e.g., orIds, ClientId, WarehouseId]
Query Causing the Error
DbSet<JoinKey<long>>().FromSql(SELECT [Id] FROM @orIds, @p)
.Join(
inner: DbSet<OR>()
.IgnoreQueryFilters(),
outerKeySelector: e => e.Id,
innerKeySelector: e => e.ORId,
resultSelector: (_, e) => e)
.Where(e => (int?)e.ClientId == @_tenantInfo_ClientId)
.Where(e => (int?)e.WarehouseId == @_tenantInfo_WarehouseId)
.Include(x => x.ORDetails)
.AsSplitQuery()
### Your code
```csharp
DbSet<JoinKey<long>>().FromSql(SELECT [Id] FROM @orIds, @p)
.Join(
inner: DbSet<OR>()
.IgnoreQueryFilters(),
outerKeySelector: e => e.Id,
innerKeySelector: e => e.ORId,
resultSelector: (_, e) => e)
.Where(e => (int?)e.ClientId == @_tenantInfo_ClientId)
.Where(e => (int?)e.WarehouseId == @_tenantInfo_WarehouseId)
.Include(x => x.ORDetails)
.AsSplitQuery()
Stack traces
Microsoft.EntityFrameworkCore.Query: Debug: Including navigation: 'OR.ORDetails'.
Exception thrown: 'System.InvalidOperationException' in Microsoft.EntityFrameworkCore.Relational.dll
'Unable to translate a collection subquery in a projection since either parent or the subquery doesn't project necessary information required to uniquely identify it and correctly generate results on the client side. This can happen when trying to correlate on keyless entity type. This can also happen for some cases of projection before 'Distinct' or some shapes of grouping key in case of 'GroupBy'. These should either contain all key properties of the entity that the operation is applied on, or ...'
The thread '.NET TP Worker' (83024) has exited with code 0 (0x0).
Verbose output
EF Core version
10.0.10
Database provider
No response
Target framework
NET 10
Operating system
No response
IDE
No response
- Lenguaje dominante
- C#
- Estrellas
- 14.8k
- Forks
- 3.5k
- Merge medio
- 2 d 22 h
- PR fusionados (30 d)
- 158
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de dotnet/efcore
-
Test bug: Include_collection_with_cross_apply_with_filter relies on nondeterministic ORDER BY with TakePosiblemente ocupada @Mohamedadel-prog la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
dotnet/efcore#39848 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
customer-reported
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 2 días
-
Compiled model: generate a deterministic model IDPosiblemente ocupada @rgroenewoudt la tomó hoy. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
Los mantenedores suelen responder en 2 días
-
customer-reported
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
Los mantenedores suelen responder en 2 días
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
Los mantenedores suelen responder en 2 días
Todos los issues de dotnet/efcore
Issues similares
-
area-VM-meta-mono untriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
BattletechModders/ModTek#256 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
microsoft/sqltoolsservice#2851 ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
triage/untriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
unoplatform/uno#26844 ·
Los mantenedores suelen responder en 1 día