Link to home
Start Free TrialLog in
Avatar of g_johnson
g_johnsonFlag for United States of America

asked on

Linq to Sql, InsertAllOnSubmit

using linq to sql, I need to insert two records on each iteration through a loop (perhaps 2000 times)

I know I can use this technique
    table_sql tbl1 = new table_sql();
    // set the column values for table_sql
    dc.table_sqls.InsertOnSubmit(tbl1);

    table_sql tbl2 = new table_sql();
    // set the column values for table_sql
    dc.table_sqls.InsertOnSubmit(tbl2);

    Then do dc.SubmitChanges from the calling loop (because other things happen in the loop, too)

I assume, however, that it would be better to use an InsertAllOnSubmit for this in that it would cut the number of connection open/close operations in half.

How do I use InsertAllOnSubmit for this?
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial