Example #1
0
        public async Task <int> ExecuteNonQueryAsync(string sql, IEnumerable <SqliteParameter> parameters, SqliteTransaction transaction, CancellationToken cancellationToken)
        {
            using (var monitor = new QueryMonitor(sql, _internalLogger))
            {
                await OpenConnectionAsync(cancellationToken);

                var command = _connection.CreateCommand();
                command.CommandText = sql;

                if (parameters != null)
                {
                    command.Parameters.AddRange(parameters);
                }

                command.Transaction = transaction;

                try
                {
                    return(await command.ExecuteNonQueryAsync(cancellationToken));
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Example #2
0
        public async Task <object> ExecuteScalarAsync(string sql, CancellationToken cancellationToken)
        {
            using (var monitor = new QueryMonitor(sql, _internalLogger))
            {
                await OpenConnectionAsync(cancellationToken);

                var command = _connection.CreateCommand();
                command.CommandText = sql;
                return(await command.ExecuteScalarAsync(cancellationToken));
            }
        }