Beispiel #1
0
        /// <summary>Commit changes made to the collection.</summary>
        async Task ICollectionRef <T> .Commit()
        {
            try
            {
                using LiteRepository _liteRepo = new LiteRepository(RefConfig.Location);
                if (ToSave.Any() || ToModify.Any())
                {
                    IList <T> _combinedList = ToSave.Concat(ToModify).ToList();
                    _liteRepo.Upsert <T>(_combinedList, RefConfig.Collection);
                }
                if (ToRemove.Any())
                {
                    BsonValue[] _bsonValues = ToRemove.Select(_id => new BsonValue(_id)).ToArray();
                    _liteRepo.DeleteMany <T>(Query.In("_id", _bsonValues), RefConfig.Collection);
                }

                await Task.Run(() =>
                {
                    ToSave.Clear();
                    ToModify.Clear();
                    ToRemove.Clear();
                });
            }
            catch (Exception ex)
            { throw ex; }
        }
 public async Task Purge(DateTime minimumDate)
 {
     using (await _dbLock.LockAsync())
     {
         using (var repository = new LiteRepository(_connectionString))
         {
             repository.DeleteMany <Trace>(x => x.ContactTimestamp <= minimumDate);
         }
     }
 }
 public async Task ClearAsync()
 {
     using (await _dbLock.LockAsync())
     {
         using (var repository = new LiteRepository(_connectionString))
         {
             repository.DeleteMany <Trace>((x) => true);
         }
     }
 }
Beispiel #4
0
 /// <inheritdoc />
 public void RemoveSettings(Guid pluginGuid)
 {
     _repository.DeleteMany <PluginSettingEntity>(s => s.PluginGuid == pluginGuid);
 }