GroupJoin
public class Entity
{
public ObjectId id;
public string name { get; set; }
}
var query = entities.AsQueryable()
.Where(p => listNames.Contains(p.name))
.GroupJoin(
others.AsQueryable(),
p => p.id,
o => o.entity,
(p, o) => new { p.id, p.name, other = o.First() }
)
.OrderByDescending(p => p.other.name);
Mongo db c# driver - how to join by id in collection?
Class A
{
public string id;
public string name;
public list<string> classBReferenceid; // <--- I want use this as the "keys" for the join
public list<B> myBs;
}
Class B
{
public string id; // <--- I use this as the "key" for the join
public string name;
}
IMongoCollection<A> mongoACollection = // already set in driver....
IMongoCollection<B> mongoBCollection = // already set in driver....
IAggregateFluent<A> results = _mongoACollection.Aggregate().
Lookup<A, B, A>(
mongoBCollection,
a => a.classBReferenceid,
b => b.Id,
a => a.myBs);
Querying an Untyped Object Inside MongoDB