How can I Use transaction?
Great repository. Truly exceptional. Thanks.
I have a request. How do I use transactions in the "service layer"? For example: I have a "UserService" and one method performs two inserts that are dependent on each other. My need is to cancel the first entry in case the second goes wrong and rollback transaction. I noticed that the transaction logic is implemented in the Repository layer, but this way how can I use them.? The only thing I can do at the moment is passing a param "useTransaction". If is true it uses transaction but that's not what I need.
Best regards
Great repository. Truly exceptional. Thanks.
I have a request. How do I use transactions in the "service layer"? For example: I have a "UserService" and one method performs two inserts that are dependent on each other. My need is to cancel the first entry in case the second goes wrong and rollback transaction. I noticed that the transaction logic is implemented in the Repository layer, but this way how can I use them.? The only thing I can do at the moment is passing a param "useTransaction". If is true it uses transaction but that's not what I need.
Best regards
Sorry I just saw now, first of all, I don't recommend that you do transactional operations in the service layer, which is not conducive to code management, and it is very easy to do it in the Data layer. But if you must,
- You can use TransactionScope, but it doesn't have a rollback mechanism
- I can help you modify the code remotely to implement the service layer using database transactions