I've been looking at the aggregation and lookup functions of mongo to figure out how to search by a field in a different collection but could not work it out.
The data structure looks like this:
public class User
{
public string Id
public string Name
public string GroupId
}
and
public class Group
{
public string Id
public string Name
}
What I'm trying to accomplish here is: return a list of Users with Group name "xyz".
Below is my returned IExecutable with no matching field for the group name.
return userCollection.Aggregate(new AggregateOptions
{
Collation = new Collation("en",
strength: CollationStrength.Primary)
})
.Match(u=>u.Name.Contains("xyz")
.AsExecutable();