C# Class CoreTechs.Common.Database.SqlDataTransfer

Provides the ability to bulk insert data from a source table (or query) into a destination table. SQL Server only.
Mostrar archivo Open project: Core-Techs/Common

Public Methods

Method Description
SqlDataTransfer ( string sourceConnectionString, string destinationConnectionString ) : System
TransferData ( string tableName, string query = null, SqlParameter queryParams = null, SqlBulkCopyOptions sqlBulkCopyOptions = SqlBulkCopyOptions.Default, SqlTransaction sqlTransaction = null, Action sqlBulkCopyCustomizer = null, bool smartColumnMapping = true ) : void

Transfer data into a destination table.

Private Methods

Method Description
MapColumns ( DataTable sourceSchema, System.Data.SqlClient.SqlBulkCopy bcp, SqlConnection dest ) : void

Method Details

SqlDataTransfer() public method

public SqlDataTransfer ( string sourceConnectionString, string destinationConnectionString ) : System
sourceConnectionString string
destinationConnectionString string
return System

TransferData() public method

Transfer data into a destination table.
public TransferData ( string tableName, string query = null, SqlParameter queryParams = null, SqlBulkCopyOptions sqlBulkCopyOptions = SqlBulkCopyOptions.Default, SqlTransaction sqlTransaction = null, Action sqlBulkCopyCustomizer = null, bool smartColumnMapping = true ) : void
tableName string /// The name of the table that will be written to. /// If a query is not provided this will also be the name of the table that data is read from.
query string An optional query that will be used as the source of data.
queryParams System.Data.SqlClient.SqlParameter Optional parameters that are used by the source data query.
sqlBulkCopyOptions SqlBulkCopyOptions Options used by .
sqlTransaction System.Data.SqlClient.SqlTransaction Optional object that will be used to construct the .
sqlBulkCopyCustomizer Action Optional delegate that can customize the object.
smartColumnMapping bool /// Passing true will cause source columns to be mapped to destination columns by name and computed columns to be ignored. /// A value of false will result in ordinal based mapping of all columns. Defaults to true. ///
return void