我使用的是ServiceStack OrmLite SqlServer v3.9.71,并具有以下连接字符串:
<add key="ConnStr" value="Data Source=my-db;Initial Catalog=Users;Integrated Security=SSPI;Connection Timeout=666"/>正在使用以下内容运行一个查询,该查询需要2-3分钟才能返回:
using (Db)
{
var result = new ResultDto();
Parallel.Invoke(
() => { result.StatOne = Db.Dictionary<DateTime, int>(query1); },
() => { result.StatTwo = Db.Dictionary<DateTime, int>(query2); }
);
return result;
}当在Db对象上放置断点时,我可以看到连接超时为666,但每次运行上面的命令超时时,我都想不出如何设置/增加命令超时--这是30秒(默认超时)之后的超时。
有什么想法吗?
发布于 2014-09-18 11:17:47
超时可以在OrmLite中使用OrmLiteConfig.CommandTimeout设置,作为全局配置,可以是静态配置,也可以在StartUp上设置一次:
OrmLiteConfig.CommandTimeout = 666;或者,您可以将CommandTimeout作用域设置为特定的db连接:
using (var db = DbFactory.Open())
{
db.SetCommandTimeout(60);
db.Select(...);
}https://stackoverflow.com/questions/25908617
复制相似问题