public DeleteResult Delete(TKey id)
        {
            if (_inmemoryCollection.IsActive)
            {
                return(new DeleteResult
                {
                    Ok = true,
                    DocumentsAffected = _inmemoryCollection.Delete(id) ? 1 : 0
                });
            }

            return(_storage.Delete(id));
        }
Exemple #2
0
        public void can_delete_by_id()
        {
            var model = new SampleReadModelWithStringKey()
            {
                Id = "a"
            };

            _inmemoryCollection.Save(model);

            _inmemoryCollection.Delete("a");

            Assert.AreEqual(0, _inmemoryCollection.GetAll().Count());
        }
Exemple #3
0
        public DeleteResult Delete(TKey id)
        {
            if (_inmemoryCollection.IsActive)
            {
                var instance = _inmemoryCollection.GetById(id);
                _indexes.RemoveInstance(instance);
                return(new DeleteResult
                {
                    Ok = true,
                    DocumentsAffected = _inmemoryCollection.Delete(id) ? 1 : 0
                });
            }

            return(_storage.Delete(id));
        }
        public async Task <DeleteResult> DeleteAsync(TKey id)
        {
            if (_inmemoryCollection.IsActive)
            {
                var instance = _inmemoryCollection.GetById(id);
                _indexes.RemoveInstance(instance);
                return(new DeleteResult
                {
                    Ok = true,
                    DocumentsAffected = _inmemoryCollection.Delete(id) ? 1 : 0
                });
            }

            return(await _storage.DeleteAsync(id).ConfigureAwait(false));
        }