I need to be all my entire application transactional in its every web request it processes.
I need the transaction to start and, if there was no exceptions in controllers, commit it. Otherwise, rollback.
So far, I have the following implementation:
- First, I create transaction on controller as a dependency.
- Then, I do my controller/service/repositories/other stuff work.
- And finally, the main abstract controller class executes its
OnActionExecuted
method, where I either commit it or I don't.
Here goes the list of technologies that I use:
- MVC 4
- Ninject
- Automapper
- Service pattern
Now, what I want to know is what about the deadlocks? What will happen when two web requests will be simultaneously processed, and besides they will acquire the right to work with two repositories (which are linked to the theirs DataContext
instances), and which means, two tables in the database?
For example: one request at first wants to read table Table1
and then Table2
, in meantime the other request wants to work with Table2
and then with Table1
.
What should I do?