public async Task ExecuteAsync(CancellationToken cancellationToken, ImportOptions options, string commandText, string destinationTable, params object[] commandParameters) { SqlScope scope = TransactionFrom == null ? new SqlScope(ConnectionFrom) : new SqlScope(TransactionFrom); using (DbDataReader reader = await scope.CreateSimple(options.QueryOptions, commandText, commandParameters).ExecuteReaderAsync(cancellationToken).ConfigureAwait(false)) { if (TransactionTo == null) { await reader.WriteToServerAsync(cancellationToken, options.BulkOptions, ConnectionTo, destinationTable).ConfigureAwait(false); } else { await reader.WriteToServerAsync(cancellationToken, options.BulkOptions, TransactionTo, destinationTable).ConfigureAwait(false); } } }
public void Execute(ImportOptions options, string commandText, string destinationTable, params object[] commandParameters) { SqlScope scope = TransactionFrom == null ? new SqlScope(ConnectionFrom) : new SqlScope(TransactionFrom); using (DbDataReader reader = scope.CreateSimple(options.QueryOptions, commandText, commandParameters).ExecuteReader()) { if (TransactionTo == null) { reader.WriteToServer(options.BulkOptions, ConnectionTo, destinationTable); } else { reader.WriteToServer(options.BulkOptions, TransactionTo, destinationTable); } } }
public Task ExecuteAsync(ImportOptions options, string commandText, string destinationTable, params object[] commandParameters) { return ExecuteAsync(CancellationToken.None, options, commandText, destinationTable, commandParameters); }
public static async Task ExecuteAsync(CancellationToken cancellationToken, ImportOptions options, string connectionStringFrom, string connectionStringTo, string commandText, string destinationTable, params object[] commandParameters) { using (SqlConnection connFrom = new SqlConnection(connectionStringFrom)) { await connFrom.OpenAsync().ConfigureAwait(false); using (SqlConnection connTo = new SqlConnection(connectionStringTo)) { await connTo.OpenAsync().ConfigureAwait(false); Import import = new Import(connFrom, connTo); await import.ExecuteAsync(cancellationToken, options, commandText, destinationTable, commandParameters).ConfigureAwait(false); } } }
public static void Execute(ImportOptions options, string connectionStringFrom, string connectionStringTo, string commandText, string destinationTable, params object[] commandParameters) { using (SqlConnection connFrom = new SqlConnection(connectionStringFrom)) { connFrom.Open(); using (SqlConnection connTo = new SqlConnection(connectionStringTo)) { connTo.Open(); Import import = new Import(connFrom, connTo); import.Execute(options, commandText, destinationTable, commandParameters); } } }