Example #1
0
        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)));
        }
Example #2
0
        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))));
        }
Example #3
0
        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)));
        }