Git Product home page Git Product logo

alfxp / entityframeworkcore.sqlserver.simplebulks Goto Github PK

View Code? Open in Web Editor NEW

This project forked from phongnguyend/entityframeworkcore.sqlserver.simplebulks

0.0 1.0 0.0 78 KB

A very simple .net core 3.1 library (lightweight, easy to use and customize) that supports bulk insert, bulk update, bulk delete and bulk merge database operations. Lambda Expression is also supported.

License: MIT License

C# 100.00%

entityframeworkcore.sqlserver.simplebulks's Introduction

EntityFrameworkCore.SqlServer.SimpleBulks

This is a very simple .net core library that can help to work with large number of records using the SqlBulkCopy class. ย 

Overview

This library provides extension methods so that you can use with your EntityFrameworkCore DbContext instance: DbContextExtensions.cs or you can use SqlConnectionExtensions.cs to work directly with a SqlConnection instance.

EntityFrameworkCore.SqlServer.SimpleBulks supports:

  • Bulk Insert
  • Bulk Update
  • Bulk Delete
  • Bulk Merge

Examples

Using Dynamic String:

dbct.BulkInsert(rows, "Rows",
    new string[] { "Column1", "Column2", "Column3" });
dbct.BulkInsert(rows.Take(1000), "Rows",
    typeof(Row).GetDbColumnNames("Id"));
dbct.BulkInsert(compositeKeyRows, "CompositeKeyRows",
    new string[] { "Id1", "Id2", "Column1", "Column2", "Column3" });

dbct.BulkUpdate(rows, "Rows",
    "Id",
    new string[] { "Column3", "Column2" });
dbct.BulkUpdate(compositeKeyRows, "CompositeKeyRows",
    new string[] { "Id1", "Id2" },
    new string[] { "Column3", "Column2" });

dbct.BulkMerge(rows, "Rows",
    "Id",
    new string[] { "Column1", "Column2" },
    new string[] { "Column1", "Column2", "Column3" });
dbct.BulkMerge(compositeKeyRows, "CompositeKeyRows",
    new string[] { "Id1", "Id2" },
    new string[] { "Column1", "Column2", "Column3" },
    new string[] { "Id1", "Id2", "Column1", "Column2", "Column3" });

dbct.BulkDelete(rows, "Rows", "Id");
dbct.BulkDelete(compositeKeyRows, "CompositeKeyRows", new List<string> { "Id1", "Id2" });

Using Lambda Expression:

// Register Type - Table Name globaly
TableMapper.Register(typeof(Row), "Rows");
TableMapper.Register(typeof(CompositeKeyRow), "CompositeKeyRows");

dbct.BulkInsert(rows,
    row => new { row.Column1, row.Column2, row.Column3 });
dbct.BulkInsert(compositeKeyRows,
    row => new { row.Id1, row.Id2, row.Column1, row.Column2, row.Column3 });

dbct.BulkUpdate(rows,
    row => row.Id,
    row => new { row.Column3, row.Column2 });
dbct.BulkUpdate(compositeKeyRows,
    row => new { row.Id1, row.Id2 },
    row => new { row.Column3, row.Column2 });

dbct.BulkMerge(rows,
    row => row.Id,
    row => new { row.Column1, row.Column2 },
    row => new { row.Column1, row.Column2, row.Column3 });
dbct.BulkMerge(compositeKeyRows,
    row => new { row.Id1, row.Id2 },
    row => new { row.Column1, row.Column2, row.Column3 },
    row => new { row.Id1, row.Id2, row.Column1, row.Column2, row.Column3 });
                        
dbct.BulkDelete(rows, row => row.Id);
dbct.BulkDelete(compositeKeyRows, row => new { row.Id1, row.Id2 });

License

EntityFrameworkCore.SqlServer.SimpleBulks is licensed under the MIT license.

entityframeworkcore.sqlserver.simplebulks's People

Contributors

phongnguyend avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.