-
Type:
Task
-
Resolution: Unresolved
-
Priority:
Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
Native LINQ query rewrite sub-project SP5 (epic EF-322). Pushes single-level collection Include onto the provider's native aggregation-pipeline path, so it no longer round-trips through the driver-LINQ provider.
Today single-level reference Include is already native (SP1: MongoSelectLowerer.AppendLookupStages emits $lookup+$unwind for streamable reference lookups). Collection lookups hit the IsStreamableReference guard, throw NativeTranslationNotSupportedException, so TryBuildNativeFactory returns null and the query falls back to driver-LINQ.
In scope:
- Single-level collection Include (Include(x => x.Orders)) emitted natively as a $lookup with NO $unwind (the collection stays an array under lookup[Nav]), materialized via the DOM shaper (IncludeCollection fixup over the array). Streaming stays off (StreamingEligibility keeps collection navs non-streamable) — DOM-only, deferring one-pass streaming of collection arrays to the materializer-perf sub-project (SP7).
- Projected collection .Count (Select(x => x.Orders.Count)) via the InjectAfterRoot $lookup + $size shape.
- Folded-in cleanup: EF-334 route-centralization — generalize the out-of-Route lookup gate (AllPendingLookupsAreStreamableReferences) to "all lookups natively renderable (reference or flat collection)" and fold it into MongoSelectDefinition.Route.
Out of scope (stay on driver-LINQ fallback; throw under NativeOnly): nested/transitive ThenInclude, filtered Include, collection-of-collection, and EF-317 ($lookup string-match hardening / plumbing cleanup — kept as a separate follow-on commit).
Native becoming the default path for collection Include and the changed emitted MQL are implementation details, not breaking changes (per the provider's versioning rubric) — query results are unchanged.
Design + plan: docs/superpowers/specs/ + docs/superpowers/plans/ (native collection includes).