Exemple #1
0
        internal IDictionary <string, object> ExecuteSingletonQuery(string insertSql, string selectSql, IEnumerable <Column> columns, IEnumerable <Object> values)
        {
            if (_transaction != null)
            {
                var command = new CommandHelper(_adapter).CreateInsert(_transaction.Connection, insertSql, columns, values.ToArray());
                command.Transaction = _transaction;
                command.TryExecuteNonQuery();
                command.CommandText = selectSql;
                command.Parameters.Clear();
                return(TryExecuteSingletonQuery(command));
            }

            var connection = _connection ?? _adapter.CreateConnection();

            using (connection.MaybeDisposable())
            {
                using (var command = new CommandHelper(_adapter).CreateInsert(connection, insertSql, columns, values.ToArray()))
                {
                    connection.OpenIfClosed();
                    command.TryExecuteNonQuery();
                    command.CommandText = selectSql;
                    command.Parameters.Clear();
                    return(TryExecuteSingletonQuery(command));
                }
            }
        }
Exemple #2
0
        internal int Execute(string sql, IEnumerable <Column> columns, IEnumerable <Object> values)
        {
            if (_transaction != null)
            {
                var command = new CommandHelper(_adapter).CreateInsert(_transaction.Connection, sql, columns, values.ToArray());
                command.Transaction = _transaction;
                return(command.TryExecuteNonQuery());
            }
            var connection = _connection ?? _adapter.CreateConnection();

            using (connection.MaybeDisposable())
            {
                using (var command = new CommandHelper(_adapter).CreateInsert(connection, sql, columns, values.ToArray()))
                {
                    connection.OpenIfClosed();
                    return(command.TryExecuteNonQuery());
                }
            }
        }
 private static int Execute(AdoAdapter adapter, string sql, IEnumerable<Column> columns, IEnumerable<Object> values,
                     IDbTransaction transaction)
 {
     if (transaction != null)
     {
         var command = new CommandHelper(adapter).CreateInsert(transaction.Connection, sql, columns,
                                                               values.ToArray());
         command.Transaction = transaction;
         return command.TryExecuteNonQuery();
     }
     var connection = adapter.CreateConnection();
     using (connection.MaybeDisposable())
     {
         using (var command = new CommandHelper(adapter).CreateInsert(connection, sql, columns, values.ToArray())
             )
         {
             connection.OpenIfClosed();
             return command.TryExecuteNonQuery();
         }
     }
 }
 internal int Execute(string sql, IEnumerable<Column> columns, IEnumerable<Object> values)
 {
     if (_transaction != null)
     {
         var command = new CommandHelper(_adapter).CreateInsert(_transaction.Connection, sql, columns, values.ToArray());
         command.Transaction = _transaction;
         return command.TryExecuteNonQuery();
     }
     var connection = _connection ?? _adapter.CreateConnection();
     using (connection.MaybeDisposable())
     {
         using (var command = new CommandHelper(_adapter).CreateInsert(connection, sql, columns, values.ToArray()))
         {
             connection.OpenIfClosed();
             return command.TryExecuteNonQuery();
         }
     }
 }
        internal IDictionary<string, object> ExecuteSingletonQuery(string insertSql, string selectSql, IEnumerable<Column> columns, IEnumerable<Object> values)
        {
            if (_transaction != null)
            {
                var command = new CommandHelper(_adapter).CreateInsert(_transaction.Connection, insertSql, columns, values.ToArray());
                command.Transaction = _transaction;
                command.TryExecuteNonQuery();
                command.CommandText = selectSql;
                command.Parameters.Clear();
                return TryExecuteSingletonQuery(command);
            }

            var connection = _connection ?? _adapter.CreateConnection();
            using (connection.MaybeDisposable())
            {
                using (var command = new CommandHelper(_adapter).CreateInsert(connection, insertSql, columns, values.ToArray()))
                {
                    connection.OpenIfClosed();
                    command.TryExecuteNonQuery();
                    command.CommandText = selectSql;
                    command.Parameters.Clear();
                    return TryExecuteSingletonQuery(command);
                }
            }
        }