private void apply()
        {
            var transform = _session.Tenant.TransformFor(StoreOptions.PatchDoc);
            var storage   = _session.StorageFor(typeof(T));

            ISqlFragment where;
            if (_filter == null)
            {
                var statement = new StatementOperation(storage, null);
                statement.ApplyFiltering(_session, _filterExpression);

                where = statement.Where;
            }
            else
            {
                where = storage.FilterDocuments(null, _filter);
            }

            var operation = new PatchOperation(transform, storage, where, Patch, _session.Serializer)
            {
                PossiblyPolymorhpic = PossiblyPolymorphic
            };

            _session.QueueOperation(operation);
        }
Exemple #2
0
        public void UndoDeleteWhere <T>(Expression <Func <T, bool> > expression) where T : notnull
        {
            assertNotDisposed();


            var documentStorage = StorageFor <T>();

            if (documentStorage.DeleteFragment is HardDelete)
            {
                throw new InvalidOperationException("Un-deleting documents can only be done against document types configured to be soft-deleted");
            }
            var deletion = new StatementOperation(documentStorage, new UnSoftDelete(documentStorage));


            var @where = deletion.ApplyFiltering(this, expression);

            // This is hokey, but you need to remove the normally applied filter
            // to exclude soft-deleted documents because that's exactly what you do want
            // here
            if (@where is CompoundWhereFragment compound)
            {
                var filter = compound.Children.OfType <ExcludeSoftDeletedFilter>().FirstOrDefault();
                if (filter != null)
                {
                    compound.Remove(filter);
                }
            }


            _workTracker.Add(deletion);
        }
Exemple #3
0
        public void HardDeleteWhere <T>(Expression <Func <T, bool> > expression) where T : notnull
        {
            assertNotDisposed();

            var documentStorage = StorageFor <T>();
            var deletion        = new StatementOperation(documentStorage, documentStorage.HardDeleteFragment);

            deletion.ApplyFiltering(this, expression);

            _workTracker.Add(deletion);
        }
Exemple #4
0
        public void Where <T>(string transformName, Expression <Func <T, bool> > @where)
        {
            var transform = Session.Options.TransformFor(transformName);

            var storage   = Session.StorageFor <T>();
            var operation = new DocumentTransformOperationFragment(storage, transform);

            var statement = new StatementOperation(storage, operation);

            statement.ApplyFiltering(Session, @where);
            Session.QueueOperation(statement);
        }
Exemple #5
0
        public void Where <T>(string transformName, Expression <Func <T, bool> > @where)
        {
            var transform = _tenant.TransformFor(transformName);
            var mapping   = _tenant.MappingFor(typeof(T));

            using var session = (DocumentSessionBase)_store.LightweightSession();
            var operation = new DocumentTransformOperationFragment(mapping, transform);
            var statement = new StatementOperation(session.StorageFor <T>(), operation);

            statement.ApplyFiltering(session, @where);
            session.UnitOfWork.Add(statement);
            session.SaveChanges();
        }