i am attempting to update approximately 150,000 records in a table in SQL 2005 using linq2sql. When it comes to xx.SubmitChanges() it is taking about 45 minutes.
I am running sql as a local instance on a quad core pc.
Does anyone know why this is taking so long? or is that normal?
Code Sample:
var y = db.x.Where(j => j.NumberOfOrders > 0).Select(k => k);
foreach (var item in y)
{
try
{
item.k = "bla";
}
catch (Exception ex)
{
//
}
}
db.SubmitChanges();
this will take much time there is no bulk insert in linq to sql.In this case it is inserting one by one record to your context and finally its goes and save in your database when you call SubmitChanges().So it is taking time.
If you have big record like 150,000 records. Better to use Bulk insert in sql.This will take only fraction of seconds only to insert .