Fastest way of performing Bulk Update in C# / .NET

前端 未结 3 681
自闭症患者
自闭症患者 2021-02-11 07:35

I\'m trying to figure out whats the best possible way to perform a bulk update via my mini console application in SQL server. I have written my own way of bulk update like follo

3条回答
  •  花落未央
    2021-02-11 08:31

    You can use Kros.KORM for bulk operation.

    using (var database = new Database("connectionstring ...", "ado client name ..."))
    {
        database
           .Query()
           .AsDbSet()
           .BulkUpdate(_data);
    }
    

    Or if you do not need to use ORM and have the source data reader available, you can use the SqlServerBulkInsert / SqlServerBulkUpdate or MsAccessBulkInsert / MsAccessBulkUpdate classes to perform bulk operations.

    For example:

    using (var bulkInsert = new SqlServerBulkInsert("connection string"))
    {
        bulkInsert.Insert(reader);
    }
    

    You can see comparison with pure ADO.NET commands https://github.com/Kros-sk/Kros.Libs/wiki

提交回复
热议问题