Prerequisites
Please answer the following questions before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.
- What is your product version? 11.01
- What is your product type (Angular or MVC)? Angular
- What is product framework type (.net framework or .net core)? .NET 6
If issue related with ABP Framework
- What is ABP Framework version? 7.01
If issue is about UI
- Which theme are you using? Default
- What are the theme settings? Default
Hi there,
Why is it necesary to call Complete() on a UnitOfWork before it get's disposed? What if you're executing multiple CRUD commands in a UnitOfWork and one of them throws an exception, and you don't want the other commands to commit their changes?
With a normal TransactionScope, if you don't want any changes in the scope to commit, you simply prevent calling Complete() on that transaction scope.
But ABP is forcing me to call Complete() on the UnitOfWork, even thought I don't want to commit the changes. This is counter intuitive. If I don't call Complete before the UnitOfWork disposes, it will throw an exception.
Secondly, If I look at the EntityFramework implementation for UnitOfWork in ABP, EfUnitOfWork, the Complete and CompleteAsync try to commit the changes on the transaction. This is not what I want or expect to happen. There should be no changes committed
Please see the two screenshots below and advise. Thank you
2 Answer(s)
-
0
Good morning @justinidsza
From your first screenshot, would it be possible to get the full context of the method this snippet is running in? Are you explicitly starting your own UnitOfWork? Or does your method have a [UnitOfWork] attribute ?
Obviously we don't want to reveal anything proprietary, but seeing the method signature and any wrapper code that encapsulates your business logic would be helpful.
Doing a little searching on the ANZ forums I found this. https://support.aspnetzero.com/QA/Questions/6926/How-to-use-IUnitOfWorkManager-when-transaction-rollback-is-required
I'm not sure if that overlaps with what you are encountering.
Let me know if you can provide more code around that first screenshot and I'm happy to try and help some more. -Brian
-
0
Hi @justinidsza
This is only necessary if you manually start a UnitOfWork, see https://aspnetboilerplate.com/Pages/Documents/Unit-Of-Work#iunitofworkmanager.
Let me know if you can provide more code around that first screenshot and I'm happy to try and help some more.
I can also take a look at your complete code.