public async Task Commit() { try { // For some odd reasons, current LiteDB version does not support transaction using (LiteRepository _liteRepo = new LiteRepository(LiteDBLocation)) { if (ToSave.Any() || ToModify.Any()) { IList <T> _combinedList = ToSave.Concat(ToModify).ToList(); _liteRepo.Upsert <T>(_combinedList, CollectionName); } if (ToRemove.Any()) { _liteRepo.Delete <T>(Query.Where("_id", id => ToRemove.Contains(id)), CollectionName); } } await Task.Run(() => { ToSave.Clear(); ToModify.Clear(); ToRemove.Clear(); }); } catch (Exception ex) { throw ex; } }
public bool Delete(T item) { using (var db = new LiteRepository(ConnectionString)) { return(db.Delete <T>(item.Id)); } }
/// <summary> /// Delete entity based on _id key /// </summary> public bool Delete <T>(BsonValue id, string collectionName = null) { using (var db = new LiteRepository(_configService.ConnectionString)) { return(db.Delete <T>(id, collectionName)); } }
public void Delete(int id) { using (var db = new LiteRepository(_pathToDb)) { db.Delete <UserProfile>(id, CollectionName); } }
/// <summary> /// Delete entity based on Query /// </summary> public int Delete <T>(Query query, string collectionName = null) { using (var db = new LiteRepository(_configService.ConnectionString)) { return(db.Delete <T>(query, collectionName)); } }
/// <summary> /// Delete entity based on predicate filter expression /// </summary> public int Delete <T>(Expression <Func <T, bool> > predicate, string collectionName = null) { using (var db = new LiteRepository(_configService.ConnectionString)) { return(db.Delete <T>(predicate, collectionName)); } }
public void Remove(string objectKey) { using (var db = new LiteRepository(_db.Context)) { db.Delete <AluguelDbModel>(new BsonValue(objectKey)); } }
public void Delete(Guid id) { using (var repo = new LiteRepository(_connectionString)) { repo.Delete <Todo>(t => t.Id == id); } }
public int DeleteProfile(string profileName) { using (var repository = new LiteRepository(_connectionStringProvider.ConnectionString)) { return(repository.Delete <InferenceProfile>(p => p.ProfileName == profileName)); } }
public bool Delete(Guid id) { using (var db = new LiteRepository(connectionString)) { var result = db.Delete <Order>(x => x.OrderNumber == id); return(Convert.ToBoolean(result)); } }
public IActionResult Delete(string id) { _db.Delete <WorkingLogItem>(item => item.Id == id); return(Content(new JObject { ["success"] = true }.ToString(Formatting.None))); }
public void Delete(int id) { using (var db = new LiteRepository(ConnectionName)) { db.Delete <QueryRecordDocument>(id); ConfigCache.Clear(); } }
public ActionResult Delete([Bind(nameof(Event.Id))][FromRoute] Event hggmEvent) { var eventGuid = hggmEvent.Id; _db.Delete <Event>(eventGuid); return(RedirectToAction(nameof(PublishedIndex))); }
public bool Delete <T>(int id) { bool _ret = false; BsonValue bsID = (BsonValue)id; _ret = _repo.Delete <T>(id); return(_ret); }
private static void SaveAnnotations(this LiteRepository repo, PdfFile document, IEnumerable <WordAnnotation> annotations, bool updatePdfLastSeen = true) { repo.EnsurePdfFile(document, updatePdfLastSeen); repo.Delete <WordAnnotation>(wa => wa.Document.Id == document.Id); repo.Insert <WordAnnotation>(annotations.Select(a => { a.Document = document; return(a); })); }
public Result <bool> Delete(BsonValue id, string collectionName = null) { var result = new Result <bool>(); try { result.ResultObject = _liteRepository.Delete <T>(id, collectionName); } catch (Exception ex) { result.ResultCode = (int)ResultStatusCode.InternalServerError; result.ResultMessage = "Hata Oluştu => " + ex; result.ResultInnerMessage = "Hata Oluştu => " + ex.InnerException; result.ResultStatus = false; } return(result); }
public void DeleteEvent(Guid id, User userWhoDeleted) { var eEvent = _db.SingleById <Event>(id); _db.Delete <Event>(id); _nService.NotifyUsers(new Notification { Message = _localizer["deleteEventMessage", userWhoDeleted.Name], Subject = _localizer["deleteEventSubject", eEvent.Name] }, GetUsersFromEvent(eEvent)); }
public void Delete(Guid id) { lock (Keylock) { using (var repo = new LiteRepository(new LiteDatabase(GetPath()), true)) { var bs = new BsonValue(id); repo.Delete <T>(bs); } } }
public void ClearPlaylist(string playlistName) { if (!string.IsNullOrWhiteSpace(playlistName)) { var playlist = jukebox.Playlists.FirstOrDefault(p => p.Name.Equals(playlistName, StringComparison.CurrentCultureIgnoreCase)); if (playlist != null) { jukebox.Playlists.Remove(playlist); using var db = new LiteRepository(cxstring); db.Delete <Playlist>(playlist.ID); } } }
public bool Excluir(int idRegistro) { EnsureNotDisposed(); var ehTransiente = EhTransiente(idRegistro); if (!ehTransiente) { int excluidos = _repositorio.Delete <Registro>(item => item.Id == idRegistro, ColecaoRegistros); return(excluidos > 0); } return(ExcluirTransiente(idRegistro)); }
public bool Delete(Expression <Func <T, bool> > where) { try { using (var db = new LiteRepository(conStr)) { // simple access to Insert/Update/Upsert/Delete int result = db.Delete <T>(where); return(result > 0 ? true : false); } } catch { return(false); } }
public void SavePlaylist(Playlist playlist) { if (playlist is null) { throw new ArgumentNullException(nameof(playlist)); } using var db = new LiteRepository(cxstring); if (playlist.Tunes.Count > 0) { db.Upsert(playlist); } else { db.Delete <Playlist>(playlist.ID); } }
public bool DeleteAllEntity() { try { using (var db = new LiteRepository(conStr)) { // simple access to Insert/Update/Upsert/Delete int result = db.Delete <T>(Query.All()); return(result > 0 ? true : false); } } catch { return(false); } }
public ActionResult Delete([Bind(nameof(Tag.Id))][FromRoute] Tag tag) { var tagId = tag.Id; var tagObj = db.SingleById <Tag>(tag.Id); db.Delete <Tag>(tagId); _audit.Add(new TagAudit() { Tag = tagObj.TagName, TagId = tag.Id.ToString(), Type = "deleted", User = _userManager.GetUserName(User), UserId = _userManager.GetUserId(User) }); return(RedirectToAction(nameof(Index))); }
public void Should_use_dynamically_registered_id_mappings() { BsonMapper.Global.RegisterIdBsonMappers(GetType().Assembly); using var repo = new LiteRepository(dbFileName).WithUtcDate(); var r1 = new Rider { Name = "Rider1" }; repo.Insert(r1); repo.Insert(new Rider { Name = "Rider2" }); repo.Query <Rider>().Count().Should().Be(2); var rider = repo.Database.GetCollection("Rider").FindAll().First(); rider["_id"].Type.Should().Be(BsonType.String); Guid.Parse(rider["_id"]).Should().NotBeEmpty(); repo.Query <Rider>().Where(x => x.Id == r1.Id).First().Should().NotBeNull(); repo.Delete <Rider>(r1.Id).Should().BeTrue(); }
public Task CleanseDatabase(Action <string> logger, Action <double> progress) { return(Task.Run(() => { logger($"Cleansing database {cxstring} for MIDI files in {jukebox.Settings.MIDIPath}"); using var db = new LiteRepository(cxstring); progress(.1d); var todelete = db.Query <Tune>() .ToEnumerable() .AsParallel() .Where(tune => !File.Exists(Path.Combine(jukebox.Settings.MIDIPath, tune.Filepath))) .ToList(); logger($"Found {todelete.Count:#,##0} Tunes that no longer exists under {jukebox.Settings.MIDIPath}"); progress(.5d); if (todelete.Any()) { todelete .Select((tune, i) => new { tune, i }) .ToList() .ForEach(e => { db.Delete <Tune>(e.tune.ID); if (e.i % 10 == 0) { progress(.5 + .5d * e.i / todelete.Count); } }); db.Database.Rebuild(); jukebox.Tunes = db.Query <Tune>().ToList(); } progress(1d); logger("Database cleanse complete"); })); }
public void RemoveUser(int id) => _liteRepository.Delete <User>(x => x.ID == id);
/// <summary> /// Deletes a user from the database based on ID. /// </summary> bool IDataService.DeleteUser(User user) { return(repo.Delete <User>(u => u.Id == user.Id) > 0); }
public async Task <int> Delete(ApplicationUser user) { return(await Task.FromResult(db.Delete <ApplicationUser>(e => e.Id == user.Id))); }
public bool Delete <T>(object id) { return(_repository.Delete <T>(new BsonValue(id))); }