The VersaTul Data Bulk project provides the ability to setup bulk coping functionality for copying data to and from different data sources. This project is designed to provide a set of common interfaces as well as implementation that can be used to build database or data source specific copiers.
$ dotnet add package VersaTul.Data.BulkVersaTul Data Bulk is a project that provides the ability to setup bulk coping functionality for copying data to and from different data sources.
To use VersaTul Data Bulk, you need to implement the IBulkCopy interface and provide the necessary parameters for the source and destination data sources. You also need to create a collection of CopyDetail objects that represent the details of the bulk copy, such as the source column, destination column, source ordinal, and destination ordinal. Then, you can call the DoCopy method to perform the bulk copy operation.
Here is a simple example using a flat file as the source:
// Create a flat file bulk copy object
FlatFileBulkCopy flatFileBulkCopy = new FlatFileBulkCopy();
// Create a collection of copy details
List<CopyDetail> copyDetails = new List<CopyDetail>();
// Add a copy detail for each column
copyDetails.Add(new CopyDetail("Name", "Name", 0, 0));
copyDetails.Add(new CopyDetail("Age", "Age", 1, 1));
copyDetails.Add(new CopyDetail("Gender", "Gender", 2, 2));
// Set the batch size and enable streaming
flatFileBulkCopy.BatchSize = 1000;
flatFileBulkCopy.EnableStreaming = true;
// Perform the bulk copy
flatFileBulkCopy.DoCopy(copyDetails);
Here is a simple example using an IDataReader as the source:
// Create a data reader bulk copy object
DataReaderBulkCopy dataReaderBulkCopy = new DataReaderBulkCopy();
// Create a collection of copy details
List<CopyDetail> copyDetails = new List<CopyDetail>();
// Add a copy detail for each column
copyDetails.Add(new CopyDetail("Name", "Name", 0, 0));
copyDetails.Add(new CopyDetail("Age", "Age", 1, 1));
copyDetails.Add(new CopyDetail("Gender", "Gender", 2, 2));
// Set the batch size and enable streaming
dataReaderBulkCopy.BatchSize = 1000;
dataReaderBulkCopy.EnableStreaming = true;
// Create a data reader from a data source
IDataReader dataReader = ...;
// Perform the bulk copy
dataReaderBulkCopy.DoCopy(dataReader, copyDetails);
This project is licensed under the MIT License - see the LICENSE file for details.