bulk insert with linq-to-sql

前端 未结 5 1978
梦谈多话
梦谈多话 2020-12-08 11:35

I have a query that looks like this:

using (MyDC TheDC = new MyDC())
{
   foreach (MyObject TheObject in TheListOfMyObjects)
   {
      DBTable TheTable = ne         


        
5条回答
  •  情话喂你
    2020-12-08 11:41

    It will generate a single insert statement for every record, but will send them all to the server in a single batch and run in a single transaction.

    That is what the SubmitChanges() outside the loop does.

    If you moved it inside, then every iteration through the loop would go off to the server for the INSERT and run in it's own transaction.

    I don't believe there is any way to fire off a SQL BULK INSERT.

提交回复
热议问题