Speed up LINQ inserts

前端 未结 11 1722
自闭症患者
自闭症患者 2021-02-01 07:46

I have a CSV file and I have to insert it into a SQL Server database. Is there a way to speed up the LINQ inserts?

I\'ve created a simple Repository method to save a rec

11条回答
  •  一整个雨季
    2021-02-01 07:48

    Have a look at the following page for a simple walk-through of how to change your code to use a Bulk Insert instead of using LINQ's InsertOnSubmit() function.

    You just need to add the (provided) BulkInsert class to your code, make a few subtle changes to your code, and you'll see a huge improvement in performance.

    Mikes Knowledge Base - BulkInserts with LINQ

    Good luck !

提交回复
热议问题