Native query: projection pushdown (server-side $project)

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Done
    • Priority: Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Dotnet Drivers
    • Not Needed
    • None
    • None
    • None
    • None
    • None
    • None

      Sub-project 3 of the native LINQ query provider rebuild (epic EF-322), built on top of sub-project 1 (EF-323), sub-project 2 (EF-329), and the EF-330 internal refactor (MongoSelectExpression extraction). Push projections down to the server as a $project stage in the native translator instead of shaping client-side.

      Scope

      • In: server-side projection — translate Select(...) projections (entity, anonymous-type, and scalar-member projections) into a native $project stage, so only the requested fields cross the wire. Extend the query AST → stage IR → BsonDocument[] lowering with a projection renderer, wired through the MongoSelectExpression scalar IR extracted in EF-330.
      • Out (later sub-projects): scalar cardinality (Count / First / Any / aggregates, SP4), collection / nested / filtered Includes (SP5), GroupBy / SelectMany / set ops / Distinct / OfType / VectorSearch / non-canonical paging (SP6), the per-row double-pass materializer fix (SP7).

      Approach

      • Build the $project document from the projection binding, driven off the native scalar IR (MongoSelectExpression).
      • Driver-LINQ stays the gated fallback: projection shapes the native renderer can't yet express fall back deterministically at compile time — no regressions.

      Acceptance

      • Zero regressions: full FunctionalTests + SpecificationTests green in Native mode on EF10 and EF8.
      • Strict-mode (MONGODB_EF_NATIVE_ONLY=1) native coverage grows vs SP2 as more projections translate natively.
      • New unit tests for rendered $project MQL of each projection shape, including parameterized-binding correctness.

      Sequencing

      • Stacked branch on top of EF-330 (which is stacked on EF-329EF-323). Rebase/retarget as the stack merges to main.

      Design docs

      • Program: 2026-06-23-native-query-provider-design.md / 2026-06-23-native-query-provider-overview.md (sub-project 3).

            Assignee:
            Arthur Vickers
            Reporter:
            Arthur Vickers
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: