Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to $lookup with MongoDB C# driver?

How do I perform a $lookup with the MongoDB C# driver? I cannot find it in their driver doc here:

https://docs.mongodb.org/getting-started/csharp/query/

But if I understand this ticket in their JIRA correctly, it should be in the 2.2 version of the driver:

https://jira.mongodb.org/browse/CSHARP-1374

like image 840
Adrian Rosca Avatar asked Nov 27 '22 16:11

Adrian Rosca


1 Answers

You can also achieve that using the collection.Aggregate().Lookup() method or by adding the lookup to the aggregate stages.

collection.Aggregate()
    .Lookup("foreignCollectionName", "localFieldName", "foreignFieldName", "result");
like image 170
M. Mennan Kara Avatar answered Dec 12 '22 14:12

M. Mennan Kara