Support LINQ LeftJoin for joins and includes

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Done
    • Priority: Unknown
    • 3.10.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • Dotnet Drivers
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      .NET 10 introduces a first-class LeftJoin operator on Queryable that enables all sorts of include and join scenarios we want to unlock not just in the driver but also in our EF Provider.

        IQueryable<TResult> LeftJoin<TOuter, TInner, TKey, TResult>(
            this IQueryable<TOuter> outer,
            IQueryable<TInner> inner,
            Expression<Func<TOuter, TKey>> outerKeySelector,
            Expression<Func<TInner, TKey>> innerKeySelector,
            Expression<Func<TOuter, TInner, TResult>> resultSelector)

      A generated pipeline for a simple left join + select looks like this:

      {{  { "$project":

      { "_outer": "$$ROOT", "_id": 0 }

      }}}
      {{  { "$lookup":

      { "from": "customers", "localField": "_outer.CustomerId", "foreignField": "_id", "as": "_inner" }

      }}}
      {{  { "$unwind":

      { "path": "$_inner", "preserveNullAndEmptyArrays": true }

      }}}
      {{  { "$project":

      { "Outer": "$_outer", "Inner": "$_inner", "_id": 0 }

      }}}

      Supported patterns:

      • Bare LeftJoin with LeftJoinResult<TOuter, TInner> result type (Include / navigation property case)
      • LeftJoin followed by .Select(), .Where(), or another .LeftJoin() (mid-pipeline chaining for ThenInclude)

      Required by the MongoDB EF Core provider to translate EF Core Include/ThenInclude navigation-property expressions without rebuilding expression trees in the provider itself.

      Cross-platform compatibility: On .NET 10+, System.Linq.Queryable.LeftJoin exists natively. To support this pattern on prior versions of .NET we'll also include a MongoQueryable.LeftJoin with the same signature so our queries work across all supported versions of .NET.

            Assignee:
            Damien Guard
            Reporter:
            Damien Guard
            None
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: