Ejemplo n.º 1
0
        public async Task RollbackAsync(IDbTransaction transaction)
        {
            SqliteTransaction sqliteTransaction = (SqliteTransaction)transaction;

            SqliteConnection connection = sqliteTransaction.Connection;

            try
            {
                await sqliteTransaction.RollbackAsync().ConfigureAwait(false);
            }
            finally
            {
                await connection.CloseAsync().ConfigureAwait(false);
            }
        }
        public async Task SaveAsync()
        {
            if (!_connection.IsValueCreated)
            {
                return;
            }

            try
            {
                await _transaction.CommitAsync();
            }
            catch (Exception e)
            {
                await _transaction.RollbackAsync();

                throw new Exception("Failed to commit changes to database", e);
            }
            finally
            {
                await _transaction.DisposeAsync();

                _transaction = (SqliteTransaction)await _connection.Value.BeginTransactionAsync();
            }
        }