且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在C#中设置超时时间限制

更新时间:2023-02-26 17:33:55

连接超时控制应用程序等待建立数据库连接的时间。它对应用程序等待数据库查询执行的时间没有影响。



您需要更改 context.Database.CommandTimeout 属性改为:

Database.CommandTimeout属性(System.Data.Entity) [ ^ ]
The connection timeout controls how long your application will wait for a database connection to be established. It has no effect on how long the application will wait for a database query to execute.

You need to change the context.Database.CommandTimeout property instead:
Database.CommandTimeout Property (System.Data.Entity)[^]