<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />

SqlBulkCopy

public sealed class SqlBulkCopy : IDisposable
Lets you efficiently bulk load a SQL Server table with data from another source.
public int BatchSize { get; set; }

Number of rows in each batch. At the end of each batch, the rows in the batch are sent to the server.

public int BulkCopyTimeout { get; set; }

Number of seconds for the operation to complete before it times out.

Returns a collection of SqlBulkCopyColumnMapping items. Column mappings define the relationships between columns in the data source and columns in the destination.

public string DestinationTableName { get; set; }

Name of the destination table on the server.

public bool EnableStreaming { get; set; }

Enables or disables a SqlBulkCopy object to stream data from an IDataReader object.

public int NotifyAfter { get; set; }

Defines the number of rows to be processed before generating a notification event.

Occurs every time that the number of rows specified by the NotifyAfter property have been processed.

public SqlBulkCopy(SqlConnection connection)

Initializes a new instance of the SqlBulkCopy class using the specified open instance of SqlConnection.

public SqlBulkCopy(SqlConnection connection, SqlBulkCopyOptions copyOptions, SqlTransaction externalTransaction)

Initializes a new instance of the SqlBulkCopy class using the supplied existing open instance of SqlConnection. The SqlBulkCopy instance behaves according to options supplied in the copyOptions parameter. If a non-null SqlTransaction is supplied, the copy operations will be performed within that transaction.

public SqlBulkCopy(string connectionString)

Initializes and opens a new instance of SqlConnection based on the supplied connectionString. The constructor uses the SqlConnection to initialize a new instance of the SqlBulkCopy class.

public SqlBulkCopy(string connectionString, SqlBulkCopyOptions copyOptions)

Initializes and opens a new instance of SqlConnection based on the supplied connectionString. The constructor uses that SqlConnection to initialize a new instance of the SqlBulkCopy class. The SqlConnection instance behaves according to options supplied in the copyOptions parameter.

public void Close()

Closes the SqlBulkCopy instance.

public void WriteToServer(DbDataReader reader)

Copies all rows from the supplied DbDataReader array to a destination table specified by the DestinationTableName property of the SqlBulkCopy object.

The asynchronous version of WriteToServer, which copies all rows from the supplied DbDataReader array to a destination table specified by the DestinationTableName property of the SqlBulkCopy object.

public Task WriteToServerAsync(DbDataReader reader, CancellationToken cancellationToken)

The asynchronous version of WriteToServer, which copies all rows from the supplied DbDataReader array to a destination table specified by the DestinationTableName property of the SqlBulkCopy object.