Data Bulk
Overview
VersaTul.Data.Bulk defines the contracts and common models for bulk-copy operations that move tabular data from one source into another destination.
It is the abstraction layer behind concrete implementations such as the SQL Server bulk-copy package.
When To Use This Package
Use this package when you want to:
Describe a bulk import in a transport-neutral way.
Define reusable source-to-destination column mappings.
Work with bulk-copy results and error reporting consistently.
Build data-loading workflows that can be backed by a specific implementation such as Data MsSql.
Installation
Install the package with the .NET CLI:
dotnet add package VersaTul.Data.Bulk
Or with the Package Manager Console:
PM> NuGet\Install-Package VersaTul.Data.Bulk -Version latest
Core Types And Concepts
IBulkCopyDefines synchronous and asynchronous bulk-copy operations plus options such as batch size and streaming.
CopyDetailDescribes a single bulk-copy unit: destination name, source
IDataReader, and column mappings.IBulkCopyColumnMappingandBulkCopyColumnMappingDefine how source columns map to destination columns by name or ordinal.
BulkCopyColumnMapping<TSource, TDestination>Strongly typed mapping helper that extracts property names from expressions.
BulkCopyResultandCopyResultCapture the overall result and per-item outcomes of a bulk operation.
BulkCopyProgressProgress payload for async operations that report incremental status.
BulkCopyExceptionWrapper exception used when a copy step fails.
Key Capabilities
IBulkCopysupports one or manyCopyDetailitems per operation.Both synchronous and asynchronous APIs are available.
Async overloads can report progress with
BulkCopyProgress.Mappings can be defined by column name, ordinal, or strongly typed expressions.
CopyDetailvalidates mappings before execution.
Basic Example
The abstraction assumes your source data is already available as an IDataReader.
using VersaTul.Data.Bulk;
var copyDetail = new CopyDetail(
destinationName: "Persons",
reader: peopleReader,
columnMappings: new[]
{
new BulkCopyColumnMapping<Person, Person>(model => model.Name, model => model.Name),
new BulkCopyColumnMapping<Person, Person>(model => model.Age, model => model.Age)
});
bulkCopy.BatchSize = 200;
bulkCopy.EnableStreaming = true;
var result = bulkCopy.DoCopy(copyDetail);
Async Progress Example
var result = await bulkCopy.DoCopyAsync(
new[] { copyDetail },
dBConnectionName: "ImportDb",
progressCallback: progress =>
{
Console.WriteLine($"Processed {progress.ProcessedItems} of {progress.TotalItems}");
});
Mapping Options
BulkCopyColumnMapping supports multiple styles:
Source name to destination name.
Source ordinal to destination ordinal.
Source ordinal to destination name.
Source name to destination ordinal.
Strongly typed expression-to-expression mapping.
Notes
VersaTul.Data.Bulkdefines the bulk-copy vocabulary; it does not by itself implement a database-specific uploader.The source side is
IDataReader-based, which makes the package fit naturally with Data FileReader and stream-based workflows.Use the concrete implementation from Data MsSql when targeting SQL Server bulk import.