使用NHibernate TransactionScope时出现超时异常

时间:2010-10-04 12:44:31

标签: nhibernate timeout castle-activerecord sqlexception

这是Timeout exception when timeout set to infinite time的延续(我也看到了未回答的问题SqlConnection and TransactionScope Timeout)。

我在NHibernate,C#3.5上使用CastleProject ActiveRecord。我在TransactionScope中有多个后续插入数据库。其中一个(随机,每次不同)因TimeoutException而失败。无论我在配置文件中设置的超时(10小时),这都没关系。如果我不使用事务范围,它可以工作(但速度太慢)。看来,NHibernate事务默认超时为30秒,并且不受hibernate.command_timeout值的影响。

这是对的吗?如何克服这个?

1 个答案:

答案 0 :(得分:1)

您是否尝试增加连接超时值?

在连接字符串中包含“Connection Timeout = somehighvalueinsecondshere”。

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectiontimeout.aspx

相关问题