在EF 6中设置命令超时 [英] Set Command Timeout in EF 6

查看:747
本文介绍了在EF 6中设置命令超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为执行查询设置命令超时,目前我正在执行context.Database.CommandTimeout = 90;,但是我感觉这不起作用, 我尝试检查数据库中的进程日志,但发现时差始终小于90秒.

I want to set command timeout for query execution, currently I am doing context.Database.CommandTimeout = 90; but i feel this is not working, I tried checking the process logs in database but found the time difference was always less than 90sec.

有人可以帮助我如何在Entity Framework 6中设置数据库超时吗?

Can someone help how can I set the database timeout in Entity Framework 6?

推荐答案

检查此内容:

实体框架6:

this.context.Database.CommandTimeout = 180;

实体框架5:

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

实体框架4及更低版本:

this.context.CommandTimeout = 180;

这篇关于在EF 6中设置命令超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆