Ejemplo n.º 1
0
 public int ExecuteNonQuery(ExecutableQueryExpression query, ParameterBag parameters = null)
 {
     var(sql, autoParameters) = ConvertQuery(query);
     using (var lease = OpenConnection())
         using (var command = CreateCommand(lease.Connection, sql, ParameterBag.Combine(autoParameters, parameters)))
         {
             return(command.ExecuteNonQuery());
         }
 }
Ejemplo n.º 2
0
 public Task <int> ExecuteNonQueryAsync(ExecutableQueryExpression query, ParameterBag parameters = null, CancellationToken cancellationToken = default)
 {
     var(sql, autoParameters) = _queryProvider.ConvertQuery(query);
     using (var command = _queryProvider.CreateCommand(_connectionLease.Connection, sql, ParameterBag.Combine(autoParameters, parameters)))
     {
         command.Transaction = _transaction;
         return(command.ExecuteNonQueryAsync());
     }
 }
Ejemplo n.º 3
0
 public int ExecuteNonQuery(ExecutableQueryExpression query, ParameterBag parameters = null)
 {
     var(sql, autoParameters) = _queryProvider.ConvertQuery(query);
     using (var command = _queryProvider.CreateCommand(_connectionLease.Connection, sql, ParameterBag.Combine(autoParameters, parameters)))
     {
         command.Transaction = _transaction;
         return(command.ExecuteNonQuery());
     }
 }
Ejemplo n.º 4
0
        public QueryResult ExecuteReader(ExecutableQueryExpression query, ParameterBag parameters = null)
        {
            var(sql, autoParameters) = _queryProvider.ConvertQuery(query);
            var command = _queryProvider.CreateCommand(_connectionLease.Connection, sql, ParameterBag.Combine(autoParameters, parameters));

            try
            {
                command.Transaction = _transaction;
                var reader = command.ExecuteReader();
                return(new QueryResult(command, reader, new RemainOpenConnectionLease(_connectionLease.Connection)));
            }
            catch
            {
                command.Dispose();
                throw;
            }
        }
Ejemplo n.º 5
0
        public virtual QueryResult ExecuteReader(ExecutableQueryExpression query, ParameterBag parameters = null)
        {
            var(sql, autoParameters) = ConvertQuery(query);
            var lease   = OpenConnection();
            var command = CreateCommand(lease.Connection, sql, ParameterBag.Combine(autoParameters, parameters));

            try
            {
                var reader = command.ExecuteReader();
                return(new QueryResult(command, reader, lease));
            }
            catch
            {
                command.Dispose();
                lease.Dispose();
                throw;
            }
        }
Ejemplo n.º 6
0
        public async Task <QueryResult> ExecuteReaderAsync(ExecutableQueryExpression query, ParameterBag parameters = null, CancellationToken cancellationToken = default)
        {
            var(sql, autoParameters) = _queryProvider.ConvertQuery(query);
            var command = _queryProvider.CreateCommand(_connectionLease.Connection, sql, ParameterBag.Combine(autoParameters, parameters));

            try
            {
                command.Transaction = _transaction;
                var reader = await command.ExecuteReaderAsync();

                return(new QueryResult(command, reader, new RemainOpenConnectionLease(_connectionLease.Connection)));
            }
            catch
            {
                command.Dispose();
                throw;
            }
        }
Ejemplo n.º 7
0
        public virtual async Task <QueryResult> ExecuteReaderAsync(ExecutableQueryExpression query, ParameterBag parameters = null, CancellationToken cancellationToken = default)
        {
            var(sql, autoParameters) = ConvertQuery(query);
            var lease = await OpenConnectionAsync(cancellationToken);

            var command = CreateCommand(lease.Connection, sql, ParameterBag.Combine(autoParameters, parameters));

            try
            {
                var reader = await command.ExecuteReaderAsync(cancellationToken);

                return(new QueryResult(command, reader, lease));
            }
            catch
            {
                command.Dispose();
                lease.Dispose();
                throw;
            }
        }
Ejemplo n.º 8
0
 public Query(ExecutableQueryExpression queryExpression, ISqlBatchProcessor processor)
 {
     QueryExpression = queryExpression;
     Processor       = processor;
 }
 public Task <QueryResult> ExecuteReaderAsync(ExecutableQueryExpression query, ParameterBag parameters = null, CancellationToken cancellationToken = default)
 => _activeQueryProvider.ExecuteReaderAsync(query, parameters);
 public QueryResult ExecuteReader(ExecutableQueryExpression query, ParameterBag parameters = null)
 => _activeQueryProvider.ExecuteReader(query, parameters);
 public int ExecuteNonQuery(ExecutableQueryExpression query, ParameterBag parameters = null)
 => _activeQueryProvider.ExecuteNonQuery(query, parameters);
 public QueryResult ExecuteReader(ExecutableQueryExpression query, ParameterBag parameters = null)
 => _transaction.ExecuteReader(query, parameters);
 public Task <int> ExecuteNonQueryAsync(ExecutableQueryExpression query, ParameterBag parameters = null, CancellationToken cancellationToken = default)
 => _transaction.ExecuteNonQueryAsync(query, parameters);
 public int ExecuteNonQuery(ExecutableQueryExpression query, ParameterBag parameters = null)
 => _transaction.ExecuteNonQuery(query, parameters);