更新时间:2023-02-16 15:30:01
先说实体框架实现了存储库模式和工作模式的单位。在现代ORM像实体框架之上实现工作模式库和单位是抽象的附加层是:
First to say Entity Framework implements a Repository pattern and a Unit of Work Pattern. Implementing Repository and Unit of Work patterns on top of a modern ORM like Entity framework is an additional layer of abstraction that:
这样的实现的目的之一是封装查询逻辑存储库,而不是一个查询像单一职责原则(的 SRP )建议,但一对夫妇的查询,从而违反了SRP。你可以做的是依靠你的ORM和单查询类封装广泛的查询逻辑。
One purpose of such implementations is to encapsulate the query logic in the Repository and not one query like Single Responsibility Principle (SRP) would suggest, but a couple of queries and thus violating SRP. What you could do is to rely on your ORM and encapsulate extensive query logic in single Query classes.
我的建议是不是通过抽象层将抽象层等讨好***做法,但尝试使用一些通用的设计指导等的 SOLID 。
My suggestion is not to please "best practices" by adding abstraction layers on abstraction layers and so on but to try to solve a problem using some more general design guidelines such as SOLID.
Ayende Rahien回顾了一系列博客文章的罗斯文入门套件的应用程序(这里,的这里,这里,的这里,这里,这里,这里和这里 )在他的博客这一协议与应用程序中适用所谓的***实践。这是一个伟大的阅读!
Ayende Rahien reviews the Northwind Starter Kit application in a series of blog posts (here, here, here, here, here, here, here and here) in his blog that deal with so called best practices applied in an application. This is a great read!