protected override void PerformSave() { var entitiesToDelete = new List <string>(); var entitiesToSave = new List <EntitySaveData>(); lock (this) { entitiesToDelete.AddRange(_entitiesToDelete); entitiesToSave.AddRange(_entitiesToSave.Values); _entitiesToDelete.Clear(); _entitiesToSave.Clear(); } if (entitiesToSave.Count > 0) { Saver.SaveEntities(entitiesToSave); } if (entitiesToDelete.Count > 0) { Saver.DeleteEntities(entitiesToDelete); } }