示例#1
0
        private static IEnumerable<IDictionary<string, object>> InsertRowsWithSeparateStatements(AdoAdapter adapter, IEnumerable<IDictionary<string, object>> data,
                                                                    IDbTransaction transaction, Table table, List<Column> columns,
                                                                    string insertSql, string selectSql)
        {
            if (transaction != null)
            {
                var insertCommand = new CommandHelper(adapter.SchemaProvider).Create(transaction.Connection, insertSql);
                var selectCommand = transaction.Connection.CreateCommand();
                selectCommand.CommandText = selectSql;
                insertCommand.Transaction = transaction;
                selectCommand.Transaction = transaction;
                return data.Select(row => InsertRow(row, columns, table, insertCommand, selectCommand)).ToList();
            }

            using (var connection = adapter.CreateConnection())
            {
                using (var insertCommand = new CommandHelper(adapter.SchemaProvider).Create(connection, insertSql))
                using (var selectCommand = connection.CreateCommand())
                {
                    selectCommand.CommandText = selectSql;
                    connection.Open();
                    return data.Select(row => InsertRow(row, columns, table, insertCommand, selectCommand)).ToList();
                }
            }
        }
 public override IEnumerable<IDictionary<string, object>> InsertRowsWithCompoundStatement(string insertSql, string selectSql)
 {
     insertSql += "; " + selectSql;
     var command = new CommandHelper(Adapter.SchemaProvider).Create(_transaction.Connection, insertSql);
     command.Transaction = _transaction;
     return Data.Select(row => InsertRowAndSelect(row, command)).ToList();
 }
 public override IEnumerable<IDictionary<string, object>> InsertRowsWithSeparateStatements(string insertSql, string selectSql, Func<IDictionary<string, object>, Exception, bool> onError)
 {
     var insertCommand = new CommandHelper(Adapter).Create(_transaction.Connection, insertSql);
     var selectCommand = _transaction.Connection.CreateCommand(Adapter.AdoOptions);
     selectCommand.CommandText = selectSql;
     insertCommand.Transaction = _transaction;
     selectCommand.Transaction = _transaction;
     return Data.Select(row => InsertRow(row, insertCommand, selectCommand, onError)).ToList();
 }
 public override IEnumerable<IDictionary<string, object>> InsertRowsWithSeparateStatements(string insertSql, string selectSql)
 {
     var insertCommand = new CommandHelper(Adapter.SchemaProvider).Create(_transaction.Connection, insertSql);
     var selectCommand = _transaction.Connection.CreateCommand();
     selectCommand.CommandText = selectSql;
     insertCommand.Transaction = _transaction;
     selectCommand.Transaction = _transaction;
     return Data.Select(row => InsertRow(row, insertCommand, selectCommand)).ToList();
 }
        public override void InsertRowsWithoutFetchBack(string insertSql, Func<IDictionary<string, object>, Exception, bool> onError)
        {
            using (var insertCommand = new CommandHelper(Adapter).Create(_transaction.Connection, insertSql))
            {
                insertCommand.Transaction = _transaction;
                foreach (var row in Data)
                {
                    InsertRow(row, insertCommand, onError);
                }
            }

        }
        public override void InsertRowsWithoutFetchBack(string insertSql)
        {
            using (var insertCommand = new CommandHelper(Adapter.SchemaProvider).Create(_transaction.Connection, insertSql))
            {
                insertCommand.Transaction = _transaction;
                foreach (var row in Data)
                {
                    InsertRow(row, insertCommand);
                }
            }

        }
        public virtual IEnumerable<IDictionary<string, object>> InsertRowsWithCompoundStatement(string insertSql, string selectSql)
        {
            insertSql += "; " + selectSql;

            using (var connection = Adapter.CreateConnection())
            {
                using (var command = new CommandHelper(Adapter.SchemaProvider).CreateInsert(connection, insertSql, _columns))
                {
                    connection.Open();
                    TryPrepare(command);
                    return Data.Select(row => InsertRowAndSelect(row, command)).ToList();
                }
            }
        }
 public virtual IEnumerable<IDictionary<string, object>> InsertRowsWithSeparateStatements(string insertSql, string selectSql)
 {
     using (var connection = Adapter.CreateConnection())
     {
         using (var insertCommand = new CommandHelper(Adapter.SchemaProvider).CreateInsert(connection, insertSql, _columns))
         using (var selectCommand = connection.CreateCommand())
         {
             selectCommand.CommandText = selectSql;
             connection.Open();
             TryPrepare(insertCommand, selectCommand);
             return Data.Select(row => InsertRow(row, insertCommand, selectCommand)).ToList();
         }
     }
 }
 public virtual IEnumerable<IDictionary<string, object>> InsertRowsWithSeparateStatements(string insertSql, string selectSql, Func<IDictionary<string, object>, Exception, bool> onError)
 {
     var connection = Adapter.CreateConnection();
     using (connection.MaybeDisposable())
     {
         using (var insertCommand = new CommandHelper(Adapter).CreateInsert(connection, insertSql, _columns))
         using (var selectCommand = connection.CreateCommand())
         {
             selectCommand.CommandText = selectSql;
             connection.OpenIfClosed();
             TryPrepare(insertCommand, selectCommand);
             return Data.Select(row => InsertRow(row, insertCommand, selectCommand, onError)).Where(r => r != null).ToList();
         }
     }
 }
示例#10
0
        public virtual IEnumerable<IDictionary<string, object>> InsertRowsWithCompoundStatement(string insertSql, string selectSql, Func<IDictionary<string, object>, Exception, bool> onError)
        {
            insertSql += "; " + selectSql;

            var connection = Adapter.CreateConnection();
            using (connection.MaybeDisposable())
            {
                using (var command = new CommandHelper(Adapter).CreateInsert(connection, insertSql, _columns))
                {
                    connection.OpenIfClosed();
                    TryPrepare(command);
                    return Data.Select(row => InsertRowAndSelect(row, command, onError)).Where(r => r != null).ToList();
                }
            }
        }
示例#11
0
 private static void InsertRowsWithoutFetchBack(AdoAdapter adapter, IEnumerable<IDictionary<string, object>> data, Table table, List<Column> columns,
                                                string insertSql)
 {
     using (var connection = adapter.CreateConnection())
     {
         using (var insertCommand = new CommandHelper(adapter.SchemaProvider).Create(connection, insertSql))
         {
             connection.Open();
             foreach (var row in data)
             {
                 InsertRow(row, columns, table, insertCommand);
             }
         }
     }
 }
示例#12
0
 public virtual void InsertRowsWithoutFetchBack(string insertSql, Func<IDictionary<string, object>, Exception, bool> onError)
 {
     var connection = Adapter.CreateConnection();
     using (connection.MaybeDisposable())
     {
         using (var insertCommand = new CommandHelper(Adapter).CreateInsert(connection, insertSql, _columns))
         {
             connection.OpenIfClosed();
             TryPrepare(insertCommand);
             foreach (var row in Data)
             {
                 InsertRow(row, insertCommand, onError);
             }
         }
     }
 }
 public virtual void InsertRowsWithoutFetchBack(string insertSql)
 {
     using (var connection = Adapter.CreateConnection())
     {
         using (var insertCommand = new CommandHelper(Adapter.SchemaProvider).CreateInsert(connection, insertSql, _columns))
         {
             connection.Open();
             TryPrepare(insertCommand);
             insertCommand.Prepare();
             foreach (var row in Data)
             {
                 InsertRow(row, insertCommand);
             }
         }
     }
 }
示例#14
0
        internal IDictionary<string, object> ExecuteSingletonQuery(string sql, params object[] values)
        {
            if (_transaction != null)
            {
                var command = new CommandHelper(_adapter.SchemaProvider).Create(_transaction.Connection, sql, values.ToArray());
                command.Transaction = _transaction;
                return TryExecuteSingletonQuery(command);
            }

            using (var connection = _adapter.CreateConnection())
            {
                using (var command = new CommandHelper(_adapter.SchemaProvider).Create(connection, sql, values.ToArray()))
                {
                    connection.Open();
                    return TryExecuteSingletonQuery(command);
                }
            }
        }
示例#15
0
        internal IDictionary<string, object> ExecuteSingletonQuery(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 TryExecuteSingletonQuery(command);
            }

            var connection = adapter.CreateConnection();
            using (connection.MaybeDisposable())
            {
                using (var command = new CommandHelper(adapter).CreateInsert(connection, sql, columns, values.ToArray()))
                {
                    connection.OpenIfClosed();
                    return TryExecuteSingletonQuery(command);
                }
            }
        }
示例#16
0
        private static IEnumerable<IDictionary<string, object>> InsertRowsWithCompoundStatement(AdoAdapter adapter, IEnumerable<IDictionary<string, object>> data,
                                                                   IDbTransaction transaction, Table table, List<Column> columns,
                                                                   string selectSql, string insertSql)
        {
            insertSql += "; " + selectSql;
            if (transaction != null)
            {
                var command = new CommandHelper(adapter.SchemaProvider).Create(transaction.Connection, insertSql);
                command.Transaction = transaction;
                return data.Select(row => InsertRowAndSelect(row, columns, table, command)).ToList();
            }

            using (var connection = adapter.CreateConnection())
            {
                using (var command = new CommandHelper(adapter.SchemaProvider).Create(connection, insertSql))
                {
                    connection.Open();
                    return data.Select(row => InsertRowAndSelect(row, columns, table, command)).ToList();
                }
            }
        }
 private IEnumerable<IDictionary<string, object>> ExecuteQuery(string sql, params object[] values)
 {
     var connection = _connection ?? _adapter.CreateConnection();
     var command = new CommandHelper(_adapter).Create(connection, sql, values);
     command.Transaction = _transaction;
     return TryExecuteQuery(connection, command);
 }
示例#18
0
 public static void SetParameterValue(this IDbCommand command, int index, object value)
 {
     ((IDbDataParameter)command.Parameters[index]).Value = CommandHelper.FixObjectType(value);
 }
        internal IDictionary<string, object> ExecuteSingletonQuery(string insertSql, string selectSql, params object[] values)
        {
            if (_transaction != null)
            {
                var command = new CommandHelper(_adapter).Create(_transaction.Connection, insertSql, values.ToArray());
                command.Transaction = _transaction;
                TryExecute(command);
                command.CommandText = selectSql;
                command.Parameters.Clear();
                return TryExecuteSingletonQuery(command);
            }

            using (var connection = _adapter.CreateConnection())
            {
                using (var command = new CommandHelper(_adapter).Create(connection, insertSql, values.ToArray()))
                {
                    connection.Open();
                    TryExecute(command);
                    command.CommandText = selectSql;
                    command.Parameters.Clear();
                    return TryExecuteSingletonQuery(command);
                }
            }
        }
 internal int Execute(string sql, params object[] values)
 {
     if (_transaction != null)
     {
         var command = new CommandHelper(_adapter).Create(_transaction.Connection, sql, values.ToArray());
         command.Transaction = _transaction;
         return TryExecute(command);
     }
     using (var connection = _adapter.CreateConnection())
     {
         using (var command = new CommandHelper(_adapter).Create(connection, sql, values.ToArray()))
         {
             connection.Open();
             return TryExecute(command);
         }
     }
 }
 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);
                }
            }
        }