Exemplo n.º 1
0
 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);
         }
     }
 }
Exemplo n.º 2
0
 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);
         }
     }
 }
Exemplo n.º 3
0
 public Task ExecuteAsync(ImportOptions options, string commandText, string destinationTable, params object[] commandParameters)
 {
     return ExecuteAsync(CancellationToken.None, options, commandText, destinationTable, commandParameters);
 }
Exemplo n.º 4
0
        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);
                }
            }
        }
Exemplo n.º 5
0
        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);
                }
            }
        }