private IEnumerable <WriteModel <T> > UpdateChangedModels(TrackedModelCollection <T> trackedModels) { var updatedModels = trackedModels.OfState(TrackedModelState.Existing).Where(m => m.IsDirty).ToArray(); var updateStrategy = UpdateStrategy.ForType <T>(); return(updatedModels.Select(m => updateStrategy.GetWriteModelForUpdate(m))); }
private IEnumerable <WriteModel <T> > DeleteRemovedModels(TrackedModelCollection <T> trackedModels) { var removedModels = trackedModels.OfState(TrackedModelState.Removed).Select(m => m.Model).ToArray(); return(removedModels.Select(m => new DeleteOneModel <T>(GenericBsonFilters.MatchSingleById(m)))); }
private IEnumerable <WriteModel <T> > InsertNewModels(TrackedModelCollection <T> trackedModels) { var newModels = trackedModels.OfState(TrackedModelState.New).Select(m => m.Model).ToArray(); return(newModels.Select(m => new InsertOneModel <T>(m))); }