I used to set Transaction timeouts by using TransactionOptions.Timeout, but have decided for ease of maintenance to use the config approach:
<system.transactions>
<defaultSettings timeout="00:01:00" />
</system.transactions>
Of course, after putting this in, I wanted to test it was working, so reduced the timeout to 5 seconds, then ran a test that lasted longer than this - but the transaction does not appear to abort! If I adjust the test to set TransactionOptions.Timeout to 5 seconds, the test works as expected
After Investigating I think the problem appears to relate to TransactionOptions.Timeout, even though I'm no longer using it.
I still need to use TransactionOptions so I can set IsolationLevel, but I no longer set the Timeout value, if I look at this object after I create it, the timeout value is 00:00:00, which equates to infinity. Does this mean my value set in the config file is being ignored?
To summarise:
- Is it impossible to mix the config setting, and use of TransactionOptions
- If not, is there any way to extract the config setting at runtime, and use this to set the Timeout property
- [Edit] OR Set the default isolation-level without using TransactionOptions