[CSHARP-4246] Support concise syntax for Lookup Created: 08/Jul/22  Updated: 09/Aug/23

Status: Backlog
Project: C# Driver
Component/s: Builders
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Unknown
Reporter: Dmitry Lukyanov (Inactive) Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to CSHARP-4738 LINQ3: Support pipeline in $lookup tr... Backlog

 Description   

5.0 server has added a slightly new lookup syntax. See for details https://www.mongodb.com/docs/manual/reference/operator/aggregation/lookup/#correlated-subqueries-using-concise-syntax



 Comments   
Comment by James Kovacs [ 11/Jul/22 ]

After discussion with dmitry.lukyanov@mongodb.com, I see that we have two IAggregateFluent overloads for Lookup, one that takes a pipeline and another one that takes a localField/foreignField. We however do not have one that takes a pipeline and localField/foreignField at the same time. We will consider adding this in a future version.

Comment by James Kovacs [ 11/Jul/22 ]

If I’m understanding this correctly, MongoDB previously used a verbose syntax for $lookup:

{
   $lookup:
      {
         from: <foreign collection>,
         pipeline: [ <pipeline to run> ],
         as: <output array field>
      }
}

which required you to specify the join condition inside a $expr in the pipeline. The concise syntax adds localField and foreignField performing an equality match between these fields:

{
   $lookup:
      {
         from: <foreign collection>,
         localField: <field from local collection's documents>,
         foreignField: <field from foreign collection's documents>,
         pipeline: [ <pipeline to run> ],
         as: <output array field>
      }
}

Because of the way Join and Group are implemented in LINQ, we already use the concise syntax. So unless I'm missing some subtlety, we can close this as Done.

Generated at Wed Feb 07 21:47:40 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.