Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TransactionScopeAspectAsync Method Potential Bug #94

Open
onurkanbakirci opened this issue May 25, 2023 · 0 comments
Open

TransactionScopeAspectAsync Method Potential Bug #94

onurkanbakirci opened this issue May 25, 2023 · 0 comments

Comments

@onurkanbakirci
Copy link
Contributor

onurkanbakirci commented May 25, 2023

public static void InterceptDbContext(IInvocation invocation)
{
var db = ServiceTool.ServiceProvider.GetService(default) as DbContext;
using var transactionScope = db.Database.BeginTransaction();
try
{
invocation.Proceed();
transactionScope.Commit();
}
finally
{
transactionScope.Rollback();
}
}

In this section of TransactionScopeAspectAsync method, why finally block is being used? I think that catch block should be used instead finally to rollback in any error case. Otherwise, all transactions will be rolled back even if it is successfull.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant