Skip to content
This repository has been archived by the owner on Oct 27, 2023. It is now read-only.

YahuiWong/Dapper.Contrib.BulkInsert

Repository files navigation

Dapper.Contrib.BulkInsert

Easy to use Dapper batch insert, support MySQL, SQLServer, ClickHouse and other instances of DbConnection

Demo

Entity

    [Table("TestUser")]
    public class TestUser
    {
        [Date]
        public DateTime ResisterDate { get; set; }
        [ClickHouseColumn(Name= "ResisterTime", IsOnlyIgnoreInsert =true)]
        public DateTime ResisterTime { get; set; }
        [ColumnName("Name")]
        public string Name { get; set; }
        public int Age { get; set; }
    }

InsertBulk

MySqlConnection conn = new MySqlConnection("server=127.0.0.1;Database=Demo;Uid=root;Pwd=root");
conn.Open();
conn.Execute("CREATE TABLE IF NOT EXISTS TestUser (ResisterDate Date, ResisterTime DateTime, Name varchar(200), Age int(11)) ENGINE=InnoDB");
var user = new TestUser() { ResisterDate = DateTime.Now, ResisterTime = DateTime.Now, Age = 18, Name = "Jack" };
var user2 = new TestUser() { ResisterDate = DateTime.Now, ResisterTime = DateTime.Now, Age = 18, Name = "Tom" };

var users = new List<TestUser>() { user, user2 };
conn.InsertBulk(users);

Dapper: https://github.com/StackExchange/Dapper

ClickHouse: https://github.com/yandex/ClickHouse

ClickHouse Ado.NET Driver: https://github.com/YahuiWong/ClickHouse.Client

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages