public Task <int> DeleteAsync(object item) { if (item == null) { throw new ArgumentNullException("item"); } return(Task.Factory.StartNew(() => { SQLiteConnectionWithLock conn = GetConnection(); using (conn.Lock()) { return conn.Delete(item); } }, CancellationToken.None, _taskCreationOptions, _taskScheduler ?? TaskScheduler.Default)); }
public Task <int> DeleteAsync <T>(object pk, CancellationToken cancellationToken = default(CancellationToken)) { if (pk == null) { throw new ArgumentNullException("pk"); } return(Task.Factory.StartNew(() => { SQLiteConnectionWithLock conn = GetConnection(); using (conn.Lock()) { return conn.Delete <T>(pk); } }, cancellationToken, _taskCreationOptions, _taskScheduler ?? TaskScheduler.Default)); }
public Task <int> DeleteAsync <T>(object pk) { if (pk == null) { throw new ArgumentNullException("pk"); } return(_taskFactory.StartNew(() => { SQLiteConnectionWithLock conn = GetConnection(); using (conn.Lock()) { return conn.Delete <T>(pk); } })); }
public void RemoveRecipe(int id) { if (_isDisposed) { throw new ObjectDisposedException(nameof(RecipePersistenceService)); } using (_connection.Lock()) { _connection.RunInTransaction(() => { //Remove all fields var mapping = _connection.GetMapping <RecipeTextFieldRow>(); _connection.Execute($"DELETE FROM {mapping.TableName} WHERE RecipeId = ?", id); //Remove recipe _connection.Delete <RecipeRow>(id); }); } }
public int Delete(T entity) { //using (SQLiteConnection _dbManager = new SQLiteConnection(_baseUrl.GetDatabasePath(), WriteOnlyFlags)) using (SQLiteConnectionWithLock _dbManager = new SQLiteConnectionWithLock(new SQLiteConnectionString(_baseUrl.GetDatabasePath(), false, null), SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create | SQLiteOpenFlags.FullMutex | SQLiteOpenFlags.SharedCache)) { using (_dbManager.Lock()) { try { return(_dbManager.Delete(entity)); } catch (Exception ex) { Debug.WriteLine($"SQLiteError: {ex.Message}"); return(-1); } } } }
public void DeleteAll(System.Collections.IEnumerable collection) { foreach (var item in collection) { //using (SQLiteConnection _dbManager = new SQLiteConnection(_baseUrl.GetDatabasePath(), WriteOnlyFlags)) using (SQLiteConnectionWithLock _dbManager = new SQLiteConnectionWithLock(new SQLiteConnectionString(_baseUrl.GetDatabasePath(), false, null), SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create | SQLiteOpenFlags.FullMutex | SQLiteOpenFlags.SharedCache)) { using (_dbManager.Lock()) { try { _dbManager.Delete(item); } catch (Exception ex) { Debug.WriteLine($"SQLiteError: {ex.Message}"); } } } } }