1

From an Exrin design standpoint, should each database model have their own Service?

I find that I may need to check the same thing within the database in multiple MainModels. I figured I would create a Service for these database models to do these repeated operations and have the a service for a MainModel not only implement its own IService interface but also inherit from these database model services.

Timothy James
  • 1,062
  • 13
  • 25

1 Answers1

1

Each Database should have it's own repository class, but the service can cover many repositories.

I like to think of Services as an Aggregate Repository Layer, where you provide control logic on how the app interacts with the repositories.

If the repositories are extremely large, or it makes no sense to put them together in the same service, then by all means, split them.

However as an example, say I have a Database and an API repository. I have one service, that will retrieve data from the API or repository depending on what I am getting, and provide the information back to the app.

The premise here, is to ensure that the App doesn't concern itself with how it gets the information. The service layer is an abstraction layer on top of the repositories.

Adam
  • 16,089
  • 6
  • 66
  • 109