Recently in the process of writing an air material price. Because the execution of the statement complex, the amount of data is large, easy to cause timeouts.
Look at the hint should be the execution of SQL time out, I used LINQ in the program.
It takes about 40 seconds to actually observe the SQL statement alone.
Check the information
Sqlcommand.commandtimeout
Gets or sets the wait time before terminating an attempt to execute a command and generating an error.
The time, in seconds, to wait for the command to execute. The default is 30 seconds.
The actual observation of the time also found that the general prompt error is in the execution of the statement 30 seconds.
To resolve this problem, you can customize the time in the program to execute the statement timeout.
The traditional use of ADO
CommandTimeout = 180
LINQ can use
using (MainContext db = new MainContext()){ db.CommandTimeout = 3 * 60; // 3 Mins}
要考虑优化SQL语句,改成存储过程之类得了,看来。
An issue with ASP. NET LINQ SQL execution timeout