我有我需要使用C#來運行一次的操作:很長一段時間運行DB操作
它要複雜得多下面的代碼,但仍 是這樣的:
using (DB1DataContext db1 = new DB1DataContext())
{
int count = db1.tbale1.Count();
int currentIndex = 0;
while (currentIndex < count)
{
var obj= db1.table1s.Take(1).Skip(currentIndex).FirstOrDefault();
using (DB2DataContext db2 = new DB2DataContext())
{
tableA tb = new table1();
db2.tableAs.InsertOnSubmit(tb);
db2.SubmitChanges();
}
currentIndex++;
}
}
一個循環大約需要500毫秒,循環次數約爲15000次,這意味着操作大約需要125分鐘。
這個工作還是會出現某種問題?
編輯:正如我之前提到的只是想知道是否有任何時間限制,將停止運轉
有什麼問題嗎? – Ehsan
@EhsanUllah只是想知道是否有任何時間限制,將停止運行 – Star
你是否會在某段時間後操作超時?請參閱http://www.dbforums.com/microsoft-sql-server/1115272-how-change-query-timeout.html – Ehsan