I have this :
{
\"_id\" : ObjectId(\"4fb4fd04b748611ca8da0d48\"),
\"Name\" : \"Categories\",
\"categories\" : [{
\"_id\" : ObjectId(\"4fb4fd04b74
You can do this using FindOneAndUpdateAsync
and positional operator
public async Task Add(string productId, string categoryId, SubCategory newSubCategory)
{
var filter = Builders.Filter.And(
Builders.Filter.Where(x => x.Id == productId),
Builders.Filter.Eq("Categories.Id", categoryId));
var update = Builders.Update.Push("Categories.$.SubCategories", newSubCategory);
await collection.FindOneAndUpdateAsync(filter, update);
}