-
Type:
Task
-
Resolution: Unresolved
-
Priority:
Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
Refactor (part of the native LINQ query provider program, epic EF-322). Finish the deferred extraction of the native-translation scalar IR out of the MongoQueryExpression god-object. Pure internal refactor — no behavior change, all types internal (no public-surface break), and switching internal query representation is not a break (see the AGENTS.md versioning rubric).
Scope
- In (Phase 1): extract the native scalar slots — Predicate / Orderings / Limit / Offset / IsNativeRepresentable — into a new MongoSelectExpression composed onto MongoQueryExpression.Select. Delete the temporary MongoQueryExpression.NativeSlots.cs shim (which explicitly records it was implemented in-place "to avoid churning the QMTEV, shaper, and factory plumbing"). Update the QMTEV writer, the gate, the lowerer reader, and native unit tests to go through .Select.
- Out (Phase 2): the $lookup / inner-collection state machine (MongoQueryExpression.Lookup.cs, group 3) is shared with the driver-LINQ fallback projection-binding visitors and is already earmarked TODO(EF-317). Do NOT extract it here — fold that extraction into EF-317 / the collection-Includes sub-project (SP5), so the lookup rework happens once, with the feature that needs it.
Sequencing
- Depends on: SP1 (EF-323) and SP2 (
EF-329) merging to main first — do NOT do this on the stacked feature branches. - Do before: the next native feature sub-project (projection pushdown / SP3). Every later sub-project accretes more native-slot call sites on the god-object, so doing this first minimizes the eventual churn.
Design decisions (from the grounded plan)
- MongoSelectExpression is a plain internal sealed class data-holder — do NOT derive from System.Linq.Expressions.Expression (avoids repeating the dead VisitChildren visitor plumbing on MongoExpression). Name retained for continuity with the design doc (a comment notes it is not an Expression).
- Composition, not inheritance: MongoQueryExpression has-a get-only MongoSelectExpression Select; the QMTEV mutates its properties, never reassigns it.
Verification
- Build all three EF targets; full Query unit + functional suite; and the MONGODB_EF_NATIVE_ONLY=1 pass/fail set must be identical pre/post (only reliable "went native" signal). git grep NativeSlots returns nothing after.
Plan
- Grounded, implementation-ready plan with exact call-site census: docs/superpowers/plans/2026-07-05-extract-mongo-select-expression-plan.md. Goes through the normal design-sign-off-then-implement flow when scheduled.