i am using latest mongodb 3.2.8 with c#. i want to use joins .
Hi rahil,
As mentioned by William, you can try the aggregation operator $lookup. The $lookup operator is available starting from MongoDB v3.2.
An example of C# $lookup snippet using MongoDB .Net driver, currently at version 2.2:
var query = from p in collection.AsQueryable()
join o in otherCollection on p.Name equals o.Key into joined
select new { p.Name, AgeSum: joined.Sum(x => x.Age) };
See mongo-csharp-driver $lookup LINQ for more information.
If you are requiring joins for a frequently used query in your application or use case, I would recommend to re-consider your data models/schema.
See also the following data modelling resources:
You may also be interested to know that the next session for free online course M101N: MongoDB for .Net Developers is starting tomorrow, 2nd of August. This course will go over schema design, querying, insertion of data, indexing and working with the C# driver.
Best regards,
Wan