Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access Repository through Service or directly?

is itIa good coding standard to allow ASP.NET MVC controller actions to access a repository directly (even though a service layer is present for the heavy lifting, e.g. LoginService.Authorize() ) to retrieve, add, or update data? Or should everything go through the service, and from there to the repository?

like image 846
Alex Avatar asked Dec 20 '25 00:12

Alex


1 Answers

For smaller applications/webs, i tend not to use service layer, because it just maps Repositories methods 1:1, and I loose KISS. But in the end, it depends on business model; repository abstracts db access, and services encapsulates logic.

like image 161
Hrvoje Hudo Avatar answered Dec 21 '25 13:12

Hrvoje Hudo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!