GroupBy element `OrderBy(...).First()`/`MaxBy` over an owned type mapped to its own table fails to translate
Maintainer thường phản hồi trong vòng 2 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- csharp
- Lĩnh vực
- backend-api-design, databases
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- C#
- Star
- 14.8k
- Fork
- 3.5k
- Merge trung bình
- 3 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 182
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của dotnet/efcore
-
customer-reported
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 2 ngày
-
SQLite: Polygon.Length translates to GLength, which returns 0Có thể đã có người làm @cincuranet đã nhận hôm nay. Đang mởarea-query area-sqlite
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
dotnet/efcore#39826 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Migration lock with LockReleaseBehavior.Transaction doesn't prevent concurrent migrations since per-migration transactionsCó thể đã có người làm @AndriySvyryd đã nhận 1 ngày trước. Đang mởarea-migrations
dotnet/efcore#39824 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Querying a TPC base type with a JSON complex property throwsCó thể đã có người làm @cincuranet đã nhận 1 ngày trước. Đang mởarea-query
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 22/100
dotnet/efcore#39814 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Three Cosmos structural-equality tests flaky on Cosmos DB Emulator for WindowsCó thể đã có người làm @su-senka đã nhận 1 ngày trước. Đang mở
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 35/100
dotnet/efcore#39809 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của dotnet/efcore
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
SubtitleEdit/subtitleedit#17247 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Restore test cleanup fails on Windows when restored files are read-onlyCó thể đã có người làm @JamBalaya56562 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
duplicati/duplicati#8046 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Bundles Documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
pyrevitlabs/pyRevit#4285 ·
Maintainer thường phản hồi trong vòng 1 ngày