Question

I am currently working on a n-layer architecture with the following layers

  • View (ASP.net Web App)
  • Manager (orchestrating Services)
  • Service (Business Layer uses Unit of Work )
  • Repository (Data Access)

For now the Manager is calling one or more Services to access the data, save data or do some other business. The Service is using the implemented unit of work and the repository so that a service is used within a transaction.

Now we have a Manager which need to call different Services which all together should work within a Transaction.

My opinion is that the Unit of Work call should be keeped in the Service as the Service is accessing the Database by using the Repository. If we move the Unit of Work call to the Manager it would broke the design. The Manager would need a Reference to the Repository.

Any advise how to design the access?

Thanks!

Was it helpful?

Solution

Unit of work is not data access pattern. It is representation of logical transaction = it is part of business logic and it belongs to your manager because the manager is orchestrating logical transaction from multiple services.

Your manager is a facade (or let's call it top level service) - it is still business logic and if the logical operation requires multiple low level services they should all run in single unit of work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top