我即将建立我的服务层,我有一些疑虑。 我是否应该创建与控制器相关的特定服务(cs类+接口),还是应该创建与poco类相关的服务?服务控制器/服务poco
让我给你举个例子。 我有:StudentPoco,TeacherPoco,StudentService,TeacherService,StudentController,TeacherController。
现在形成StudentController我想调用服务的方法 - GetAllTeachers(...) - 学生希望看到一个列表。我是否应该将此函数放在StudentService中,因为我从StudentController中调用它,或者我应该将它放在TeacherService中,因为它与TeacherPocos相关 - 我们正在处理教师问题。如果我们从StudentController调用GetOnlyMyTeachers(...)会发生什么?
下一个问题:一个服务应该引用它使用的服务吗?如果StudentService引用了TeacherService并且TeacherService引用了StudentService呢?可以吗?
我想注意到我对DI很熟悉。
我首先使用MVC5和EF6代码。 我不想使用存储库和UoW模式。我将在所有服务中使用DbContext参考。多次调用savechanges方法是否正确?
你对我的疑惑有什么看法?
阅读此文章:https://www.cuttingedge.it/blogs/steven/pivot/entry.php?id=92以及下面这个:https://www.cuttingedge.it/blogs/steven/枢轴/ entry.php?ID = 91 – trailmax 2014-09-13 20:50:17