0

Currently im injecting my Unit of Work inside the controller.

I figured out that in most of the designs, controllers calls the service layer and service calls the repository/DAL layer.

Most of the times in the controller, I don't have/need any logic and just need to fetch from db and pass it to view.

I do this by calling the repository from the unit of work, is this a bad practice?

I basically have only a two layered architecture instead of a 3 tiers. Im kinda missing the service layer/application layer

Views(MVC) <- Controllers(MVC) -> UoW(DB) -> Repository(DB) -> EF(DB) -> SQL Server(DB)

For the interested i can send my git repo in private.

  • 3
    Questions containing the words "bad practice" are unanswerable unless you can articulate your specific concerns. Clearly it already works. – Robert Harvey Apr 3 at 17:13
  • 2
    You don't have to implement abstractions you don't need, regardless of what the "good practices" say. – Laiv Apr 3 at 17:38
1

If you don't really have any logic beside fetching data from the repository and showing it, then it is perfectly fine to skip a separate service/application layer. In fact it would be a bad practice to have an extra layer in that case, since you would be complicating the architecture for no benefit.

You can always introduce a new layer at a later point if the need arises.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.