在实体框架4.3设置命令超时实体、框架、命令

2023-09-02 21:54:32 作者:静听秋雨

我无法找到一个方法来设置使用实体框架4.3和它'的DbContext LINQ查询的命令超时。 如何增加的CommandTimeout在实体框架?

I cannot find the a way to set the command timeout of a linq query using entity framework 4.3 and its' DbContext. How do I increase Commandtimeout in entity framework?

修改 我其实是在寻找命令超时增加。我糊涂了两下,这是SQL命令时超时未连接。

EDIT I am actually looking for Command Timeout increase. I confused the two, it is the sql command that is timing out not the connection.

感谢

推荐答案

如果你使用的DbContext,你首先需要下降到ObjectContext的:

If you're using DbContext, you'll first need to drop down to ObjectContext:

((IObjectContextAdapter)context).ObjectContext.CommandTimeout = 180;