dotnet / dotnet/dotnet-api-docs
Clarification of exception thrown in transaction scope.
- Dominant language
- C#
- Stars
- 949
- Forks
- 1.7k
- Avg merge
- 3d 27m
- Merged PRs (30d)
- 49
Description
"If no exception occurs within the transaction scope (that is, between the initialization of the TransactionScope object and the calling of its Dispose method), then the transaction in which the scope participates is allowed to proceed. If an exception does occur within the transaction scope, the transaction in which it participates will be rolled back."
Is this intended to mean to rollback you need to exit the transaction scope by an exception and not call scope.Complete()? What about handling the exception within the scope, choosing not to rethrow the exception, and then choosing not to call scope.Complete()? I would expect the transaction to rollback in this case since scope.Complete() was not called but it sounds like it might complete anyway. Which would explain the weird behavior I am having.
---
#### Document Details
⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*
* ID: 039bbc8a-f665-3797-ff12-96cd21682bf3
* Version Independent ID: bbae7fa8-00f9-08dd-d816-ba21092f9df8
* Content: [TransactionScope Class (System.Transactions)](https://docs.microsoft.com/en-us/dotnet/api/system.transactions.transactionscope?view=netframework-4.7.2)
* Content Source: [xml/System.Transactions/TransactionScope.xml](https://github.com/dotnet/dotnet-api-docs/blob/master/xml/System.Transactions/TransactionScope.xml)
* Product: **dotnet-api**
* GitHub Login: @dotnet-bot
* Microsoft Alias: **dotnetcontent**
Contributor guide
Assessment
This issue has not been assessed yet.