For example I have a collection of Parent(s):
class Parent{
public string ParentKey {get;set;}
public IEnumerable<Child> Children {get;set;}
}
class Child{
public string ChildKey {get;set;}
public IEnumerable<GrandChild> GrandChildren {get;set;}
}
class GrandChild {
public string GrandChildKey {get;set;}
public IEnumerable<GreatGrandChild> GreatGrandChildren {get;set;}
}
class GreatGrandChild {
public string GreatGrandChildKey {get;set;}
public string SomeValue {get;set;}
}
I can do some push and pull on the Child level like this:
var filter = Builders<Parent>.Filter.Eq(p => p.ParentKey, "some-parent-key");
var pushDefinition = Builders<Parent>.Push(p => p.Children, newChild);
But I can’t figure out how to perform any operation from the GrandChildren and deeper. At least I have an idea about the filter I can use:
var filter = Builders<Parent>.Filter.And(
Builders<Parent>.Filter.Eq(p => p.ParentKey, "some-parent-key"),
Builders<Parent>.Filter.ElemMatch(p => p.Children,
Builders<Child>.Filter.Eq(c => c.ChildKey, "some-child-key"))
);