Complete `FirstWithoutOrderByAndFilterWarning` coverage for subqueries
メンテナーはふだん 2 日以内に返信
@z0rimo がすでに取り組んでいます。
2026年11月16日 から。
評価
調査の方向性
Start by reviewing PR #39218 and issue #39129 to understand the existing relational warning check; then inspect the separate Cosmos check and query translation paths for TPC, views, and FromSql. The issue lists the remaining cases and required safeguards, but leaves several behavior decisions open. Done means resolving those decisions and covering the supported cases while preserving suppression for explicit ordering, intentional filters, and correlations proven to match at most one row.
索引モデルが issue の本文から書いたものです。
説明
PR #39218 fixed #39129 for unordered First/FirstOrDefault over collection-navigation subqueries whose correlation can be identified from relational foreign-key metadata. Several cases were deliberately left out of scope.
This issue tracks the remaining diagnostic gaps and decisions about extending the warning. Some changes would introduce warnings for queries that previously ran without them; applications configuring the warning to throw would be affected.
Remaining warning coverage
-
TPC collection navigations. Detect unordered
First/FirstOrDefaultwhen the dependent source is a TPC hierarchy. Columns projected through the generatedUNIONmay lack the metadata needed by the current FK-correlation check. Account for the concrete tables without assuming that a projected column with missing metadata is a principal-key column. -
Other sources without usable table-column metadata. Investigate equivalent cases involving views and
FromSql. Warn where navigation correlation can be established reliably, without treating arbitrary user filters as relationship correlation. -
Grouping elements. Decide whether to warn for unordered selections such as
GroupBy(...).Select(g => g.First()). These can choose an arbitrary element within each group, but extending the warning affects existing queries and samples. -
Non-FK correlations. Decide whether and when to warn for queries such as
context.Others.Where(o => o.X == b.Y).FirstOrDefault(). A correlation can leave multiple candidate rows even when it does not follow a modeled relationship. Define how to distinguish this from an intentional user filter. -
Filtered unique indexes. Do not assume every filtered unique index guarantees at most one matching row. For example, a unique index on
CustomerIdfiltered to active rows still permits multiple inactive rows. Preserve suppression for SQL Server's conventional nullable unique indexes: theirIS NOT NULLfilter excludes rows that an ordinary equality correlation cannot match. The index filter is provider-specific SQL, so this needs a reliable way to establish whether uniqueness applies to the candidate rows. -
Cosmos parity. Assess the equivalent behavior for supported Cosmos query shapes. Its separate
First/FirstOrDefaultwarning check was unchanged by #39218.
Preserve intentional filters and deterministic selections
- Do not treat null checks on unrelated outer columns as navigation-generated principal-key guards. For example,
c.Orders.FirstOrDefault(o => c.City != null)contains an explicit user filter. - Account for user filters stored in
SelectExpression.Having, not onlyPredicate. For example,c.Orders.GroupBy(o => o.CustomerID).Where(g => g.Count() > 1).Select(g => g.Count()).FirstOrDefault()has an explicit filter and at most one matching group. - Continue suppressing the warning for explicit ordering and correlations proven to match at most one row. Do not infer relationship-key provenance merely from missing column metadata.
- 主要言語
- C#
- スター
- 14.8k
- フォーク
- 3.5k
- 平均マージ
- 3日 7時間
- マージ済み PR(30日)
- 182
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
dotnet/efcore のほかの issue
-
customer-reported
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 2 日以内に返信
-
GroupBy element `OrderBy(...).First()`/`MaxBy` over an owned type mapped to its own table fails to translate対応中かも @cincuranet が今日担当しました。 オープンarea-groupby area-query
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
dotnet/efcore#39833 · 担当者 1 名 ·
メンテナーはふだん 2 日以内に返信
-
SQLite: Polygon.Length translates to GLength, which returns 0対応中かも @cincuranet が今日担当しました。 オープンarea-query area-sqlite
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
dotnet/efcore#39826 · 担当者 1 名 ·
メンテナーはふだん 2 日以内に返信
-
Migration lock with LockReleaseBehavior.Transaction doesn't prevent concurrent migrations since per-migration transactions対応中かも @AndriySvyryd が 1 日前に担当しました。 オープンarea-migrations
dotnet/efcore#39824 · 担当者 1 名 ·
メンテナーはふだん 2 日以内に返信
-
Querying a TPC base type with a JSON complex property throws対応中かも @cincuranet が 1 日前に担当しました。 オープンarea-query
難易度 4/5 3〜5日 初心者へのやさしさ 22/100
dotnet/efcore#39814 · 担当者 1 名 ·
メンテナーはふだん 2 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
SubtitleEdit/subtitleedit#17247 ·
メンテナーはふだん 1 日以内に返信
-
Restore test cleanup fails on Windows when restored files are read-only対応中かも @JamBalaya56562 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
duplicati/duplicati#8046 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
Bundles Documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
pyrevitlabs/pyRevit#4285 ·
メンテナーはふだん 1 日以内に返信