Speed up LINQ inserts

前端 未结 11 1613
自闭症患者
自闭症患者 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 08:07

    This code runs ok, and prevents large amounts of data:

    if (repository2.GeoItems.GetChangeSet().Inserts.Count > 1000)
    {
        repository2.GeoItems.SubmitChanges();
    }
    

    Then, at the end of the bulk insertion, use this:

    repository2.GeoItems.SubmitChanges();
    

提交回复
热议问题