DevToys.PocoDB.BulkInsert.Core 1.1.4

dotnet add package DevToys.PocoDB.BulkInsert.Core --version 1.1.4
NuGet\Install-Package DevToys.PocoDB.BulkInsert.Core -Version 1.1.4
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="DevToys.PocoDB.BulkInsert.Core" Version="1.1.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DevToys.PocoDB.BulkInsert.Core --version 1.1.4
#r "nuget: DevToys.PocoDB.BulkInsert.Core, 1.1.4"
#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.
// Install DevToys.PocoDB.BulkInsert.Core as a Cake Addin
#addin nuget:?package=DevToys.PocoDB.BulkInsert.Core&version=1.1.4

// Install DevToys.PocoDB.BulkInsert.Core as a Cake Tool
#tool nuget:?package=DevToys.PocoDB.BulkInsert.Core&version=1.1.4

DevToys.PocoDB.BulkInsert.Core

BulkInsert wraps arround BulkInsert features for Microsoft Sql-Server specific.

Define Connectionstring configuration.

For type anything derived from DbConnection can be used. ( FbConnection, OleDbConnection, etc).


    DataConfiguration.Instance.Add<SqlConnection>(
        new ConnectionConfig()  
        {
            Key = "MySqlConfig", 
            ConnectionString = @"Server=LAPTOP-GUIDO\SQLEXPRESS;Database=Misc;Trusted_Connection=True;"  
        } 
    );
    

BulkInsert data


    [DBBulkInsert("dbo.Company")]
    public class BulkCompany
    {
        [DBParameter("Id")]
        public int Id { get; set; } = 0;

        [DBParameter("Name")]
        public string Name { get; set; } = string.Empty;

        [DBParameter("Adress")]
        public string Adress { get; set; } = string.Empty;

        [DBParameter("Country")]
        public string Country { get; set; } = string.Empty;

        [DBParameter("ZipCode")]
        public string ZipCode { get; set; } = string.Empty;

        [DBParameter("HouseNumber")]
        public string HouseNumber { get; set; } = string.Empty;

        [DBParameter("CompanyType")]
        public CompanyType CompanyType { get; set; } = CompanyType.BV;
    }


    List<BulkCompany> _data = new List<BulkCompany>();

    for (int ii = 0; ii < 10000; ii++)
        _data.Add(new BulkCompany() { Name = "Guido", ZipCode = "4624JC", CompanyType = CompanyType.LLC });

    BulkInsertOperation<BulkCompany> operation = new BulkInsertOperation<BulkCompany>("Local", 2096);
    operation.Progress += Operation_Progress;

    operation.Insert(_data);
    

    private static void Operation_Progress(object sender, BulkInsertEventArgs e)
    {
        Console.WriteLine($"RowsProcessed: {e.RowsProcessed}");
    } 

BulkInsert random data


    [DBBulkInsert("dbo.Company")]
    public class BulkCompanyRandom
    {
        [DBRandomParameter("Id")]
        public int Id { get; set; } = 0;

        [DBRandomParameter("Name", RandomStringType = RandomStringType.FullName)]
        public string Name { get; set; } = string.Empty;

        [DBRandomParameter("Adress", RandomStringType = RandomStringType.Adress)]
        public string Adress { get; set; } = string.Empty;

        [DBRandomParameter("Country", RandomStringType = RandomStringType.Country)]
        public string Country { get; set; } = string.Empty;

        [DBRandomParameter("ZipCode", RandomStringType = RandomStringType.ZipCode)]
        public string ZipCode { get; set; } = string.Empty;

        [DBRandomParameter("HouseNumber", RandomStringType = RandomStringType.Number, Min = 10, Max = 200)]
        public string HouseNumber { get; set; } = string.Empty;

        [DBRandomParameter("CompanyType")]
        public CompanyType CompanyType { get; set; } = CompanyType.BV;

        [DBParameter("Text")]
        public string Text { get; set; } = string.Empty;
    }
    

Execute to insert half a million random companies.


    BulkInsertOperation<BulkCompanyRandom> operation = new BulkInsertOperation<BulkCompanyRandom>("Local", 1024);
    operation.Progress += Operation_Progress;
    operation.Insert(500000);
    
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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. 
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
1.1.4 162 12/22/2023
1.1.3 202 4/7/2023
1.1.2 193 3/22/2023
1.1.1 450 1/28/2022
1.1.0 5,385 11/23/2021
1.0.0 320 8/26/2021