g_johnson
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.InsertOnSubm it(tbl1);
table_sql tbl2 = new table_sql();
// set the column values for table_sql
dc.table_sqls.InsertOnSubm it(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?
I know I can use this technique
table_sql tbl1 = new table_sql();
// set the column values for table_sql
dc.table_sqls.InsertOnSubm
table_sql tbl2 = new table_sql();
// set the column values for table_sql
dc.table_sqls.InsertOnSubm
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.