Skip to content

Instantly share code, notes, and snippets.

@hidegh
Created February 12, 2018 12:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hidegh/01a06f20d9e3ea97b30bc8c10ecd2688 to your computer and use it in GitHub Desktop.
Save hidegh/01a06f20d9e3ea97b30bc8c10ecd2688 to your computer and use it in GitHub Desktop.
public static TransactionScope New(TransactionScopeOption transactionScopeOption = TransactionScopeOption.Required, IsolationLevel isolationLevel = IsolationLevel.ReadCommitted, TimeSpan? timeout = null)
{
// NOTE: this is a fix, to avoid inner transaction timeout's to shorten the outer one...
if (Transaction.Current != null && transactionScopeOption == TransactionScopeOption.Required)
timeout = TimeSpan.FromMinutes(15);
var options = new TransactionOptions
{
IsolationLevel = isolationLevel,
Timeout = timeout ?? TransactionManager.DefaultTimeout
};
return new TransactionScope(transactionScopeOption, options);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment