protected override TablePair Write(IDbConnection connection, DataTable table, string tempTableName = null) { var bulkCopy = new NpgsqlBulkCopy(connection.AsNpgsqlConnection(), TableDefinitionGenerator as IPostgresTableDefinitionGenerator); if (string.IsNullOrWhiteSpace(tempTableName)) { tempTableName = CreateTempSchema(connection, table).TableName; } Write(bulkCopy, table, tempTableName); return(new TablePair(table.TableName, tempTableName)); }
protected override IDbCommand CreateDbCommand( IDbConnection connection, string query, IDictionary <string, object> parameters = null, CommandType commandType = CommandType.Text) { var sqlCommand = new NpgsqlCommand(query, connection.AsNpgsqlConnection()) { CommandType = commandType, CommandTimeout = 0 }; AddParameters(sqlCommand, parameters); return(sqlCommand); }
protected override IList <TablePair> Write(IDbConnection connection, DataSet data, IEnumerable <TablePair> tempTableMap = null) { var result = new List <TablePair>(); var bulkCopy = new NpgsqlBulkCopy(connection.AsNpgsqlConnection(), TableDefinitionGenerator as IPostgresTableDefinitionGenerator); var tempTables = tempTableMap?.ToDictionary(x => x.LiveTable, x => x.TempTable); string tempTableName = null; foreach (DataTable table in data.Tables) { if (!(tempTables?.TryGetValue(table.TableName, out tempTableName) ?? false) || string.IsNullOrWhiteSpace(tempTableName)) { tempTableName = CreateTempSchema(connection, table).TableName; } Write(bulkCopy, table, tempTableName); result.Add(new TablePair(table.TableName, tempTableName)); } return(result); }