ObjectBulkCopy 0.1.1

dotnet add package ObjectBulkCopy --version 0.1.1
                    
NuGet\Install-Package ObjectBulkCopy -Version 0.1.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ObjectBulkCopy" Version="0.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ObjectBulkCopy" Version="0.1.1" />
                    
Directory.Packages.props
<PackageReference Include="ObjectBulkCopy" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ObjectBulkCopy --version 0.1.1
                    
#r "nuget: ObjectBulkCopy, 0.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=ObjectBulkCopy&version=0.1.1
                    
Install ObjectBulkCopy as a Cake Addin
#tool nuget:?package=ObjectBulkCopy&version=0.1.1
                    
Install ObjectBulkCopy as a Cake Tool

ObjectBulkCopy

A super simple C# library for performing SqlBulkCopy directly on your CLR objects. No need to manually map properties--just plug in your list of objects and copy them to SQL Server with minimal setup. Ideal for high-performance data inserts in .NET applications.

Support Platform

  • .NET 8.0+

[!Note] It is planned to be extended to .NET Standard in the future.

How to use

using System.ComponentModel.DataAnnotations.Schema;

[Table("Users")]  // must set table name
public class User
{
    [Column("Id", Order = 0)]  // must set zero-based order
    public required int Id { get; init; }

    [Column("Name", Order = 1)]
    public required string Name { get; init; }
}
using ObjectBulkCopy;

using (var connection = new SqlConnection(...))
{
    User[] records
        = [
            new(){ Id = 0, Name = "xin9le" },
            new(){ Id = 1, Name = "Takaaki Suzuki" },
        ];
    const SqlBulkCopyOptions options = SqlBulkCopyOptions.Default;
    const int? timeout = null;
    var affectedCount = await connection.BulkInsertAsync(records, options, timeout, cancellationToken);
}

Installation

Getting started from downloading NuGet package.

dotnet add package ObjectBulkCopy

License

This library is provided under MIT License.

Author

Takaaki Suzuki (a.k.a @xin9le) is software developer in Japan who awarded Microsoft MVP for Developer Technologies (C#) since July 2012.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.1.1 142 11 days ago