예제 #1
0
 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));
 }
예제 #3
0
 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);
         }
     }));
 }
예제 #4
0
        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);
                });
            }
        }
예제 #5
0
 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);
             }
         }
     }
 }
예제 #6
0
 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}");
                 }
             }
         }
     }
 }