public async Task SetAsync(MongoStrategyParams strategyParams, Component entity) { await RemoveAsync(strategyParams); var flatVisitor = _visitorFactory.GetVisitor <FlatComponentVisitor>(); entity.Accept(flatVisitor); var flatComponents = flatVisitor.FlatElements.Values.ToList(); flatComponents.ForEach(flatComponent => flatComponent.ClearComposite()); var database = strategyParams.Database; var collection = strategyParams.Collection; await MongoClient.GetDatabase(database).GetCollection <Component>(collection).InsertManyAsync(flatComponents); }