问题
This is continuation of Timeout exception when timeout set to infinite time (and I also see unanswered SqlConnection and TransactionScope Timeout question).
I am using CastleProject ActiveRecord over NHibernate, C# 3.5. I have multiple subsequent inserts to a database within TransactionScope. One of them (random, different each time) fails with TimeoutException. Whichever timeout I set in my config file (10 hours), this does not matter. If I do not use transaction scope, it work (but too slow). It seems, NHibernate transaction has default timeout 30 second and is not affected by hibernate.command_timeout value.
Is it correct? How to overcome this?
回答1:
Have you tried increasing your connection time out value?
Include "Connection Timeout=somehighvalueinsecondshere" in the connection string.
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectiontimeout.aspx
来源:https://stackoverflow.com/questions/3855315/timeout-exception-when-using-nhibernate-transactionscope