GroupBy element `OrderBy(...).First()`/`MaxBy` over an owned type mapped to its own table fails to translate
Los mantenedores suelen responder en 2 días
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Stack tecnológico
- csharp
- Área
- backend-api-design, databases
Línea de trabajo
Read the GroupBy ordering expansion covered by #38918 and the association tests, especially the OwnedNavigations case; compare it with passing OwnedTableSplitting, OwnedJson and Navigations cases. Reproduce the supplied query with an owned type mapped via ToTable, then trace the translation failure. Done means the query returns posts 2 and 3 and the associated tests pass; linked pull request #39835 is already open.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Ordering the elements of a group by a member of an owned type, to select the first element per group, fails when the owned type is mapped to its own table. #31062 fixed this for table-split owned types in 12.0, but the ToTable case still fails on main.
// Models
class Post
{
public int Id { get; set; }
public int BlogId { get; set; }
public Timestamp Created { get; set; } = null!;
}
class Timestamp
{
public DateTime At { get; set; }
}
// EF setup
modelBuilder.Entity<Post>().OwnsOne(p => p.Created, c => c.ToTable("PostCreated"));
// Data
context.Posts.AddRange(
new Post { Id = 1, BlogId = 1, Created = new Timestamp { At = new DateTime(2026, 1, 1) } },
new Post { Id = 2, BlogId = 1, Created = new Timestamp { At = new DateTime(2026, 1, 3) } },
new Post { Id = 3, BlogId = 2, Created = new Timestamp { At = new DateTime(2026, 1, 2) } });
context.SaveChanges();
// Query: latest post per blog
var latest = context.Posts
.GroupBy(p => p.BlogId)
.Select(g => g.OrderByDescending(p => p.Created.At).First()) // or g.MaxBy(p => p.Created.At)
.ToList();
Expected: posts 2 and 3.
Actual:
InvalidOperationException: Translation of 'EF.Property<Timestamp>(StructuralTypeShaperExpression(
StructuralType: Post
ValueBufferExpression: ProjectionBindingExpression: EmptyProjectionMember
IsNullable: False), "Created")' failed. Either the query source is not an entity type, or the specified property does not exist on the entity type.
Ordering by a property of the entity itself (g.OrderByDescending(p => p.Id).First()) works in both mappings. On main, the association tests show the same split: the query passes for OwnedTableSplitting, OwnedJson and Navigations (a regular reference navigation), and fails only for OwnedNavigations, where the owned types are mapped with ToTable. #38918 expands owned navigations in GroupBy orderings when the owned type is in the same table or in JSON, but not when it needs a join.
- Lenguaje dominante
- C#
- Estrellas
- 14.8k
- Forks
- 3.5k
- Merge medio
- 3 d 7 h
- PR fusionados (30 d)
- 182
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
-
customer-reported
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 2 días
-
SQLite: Polygon.Length translates to GLength, which returns 0Posiblemente ocupada @cincuranet la tomó hoy. Abiertoarea-query area-sqlite
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
dotnet/efcore#39826 · 1 asignado ·
Los mantenedores suelen responder en 2 días
-
Migration lock with LockReleaseBehavior.Transaction doesn't prevent concurrent migrations since per-migration transactionsPosiblemente ocupada @AndriySvyryd la tomó hace 1 día. Abiertoarea-migrations
dotnet/efcore#39824 · 1 asignado ·
Los mantenedores suelen responder en 2 días
-
Querying a TPC base type with a JSON complex property throwsPosiblemente ocupada @cincuranet la tomó hace 1 día. Abiertoarea-query
Dificultad 4/5 3-5 días Aptitud para principiantes 22/100
dotnet/efcore#39814 · 1 asignado ·
Los mantenedores suelen responder en 2 días
-
Three Cosmos structural-equality tests flaky on Cosmos DB Emulator for WindowsPosiblemente ocupada @su-senka la tomó hace 1 día. Abierto
Dificultad 3/5 Medio día Aptitud para principiantes 35/100
dotnet/efcore#39809 · 1 comentario ·
Los mantenedores suelen responder en 2 días
Todos los issues de dotnet/efcore
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
SubtitleEdit/subtitleedit#17247 ·
Los mantenedores suelen responder en 1 día
-
Restore test cleanup fails on Windows when restored files are read-onlyPosiblemente ocupada @JamBalaya56562 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
duplicati/duplicati#8046 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
Bundles Documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
pyrevitlabs/pyRevit#4285 ·
Los mantenedores suelen responder en 1 día