如何在OrmLite ServiceStack中增加命令超时?

我正在使用ServiceStack OrmLite SqlServer v3.9.71并具有以下连接字符串:

 

并使用以下命令运行查询,需要2-3分钟才能返回:

 using (Db) { var result = new ResultDto(); Parallel.Invoke( () => { result.StatOne = Db.Dictionary(query1); }, () => { result.StatTwo = Db.Dictionary(query2); } ); return result; } 

当在Db对象上设置断点时,我可以看到连接超时为666但我无法弄清楚如何设置/增加命令超时每次运行上面它超过30秒后超时这是默认超时。

有任何想法吗?

可以在OrmLite中使用OrmLiteConfig.CommandTimeout设置超时,因为全局配置可以在StartUp上静态配置一次:

 OrmLiteConfig.CommandTimeout = 666; 

或者您可以将CommandTimeout作用域设置为特定的数据库连接:

 using (var db = DbFactory.Open()) { db.SetCommandTimeout(60); db.Select(...); }