[英]In ASP.NET MVC repository pattern, does every class needs to have an interface?
I'm kind of confusing what should be a repository and what should have an interface. 我有点困惑什么应该是存储库,什么应该具有接口。
Yes I know those are all for the comfort of unit tests. 是的,我知道所有这些都是为了方便进行单元测试。
Can somebody give me a hint? 有人可以给我提示吗?
Repository pattern helps you to make your application more manageable and scalable. 存储库模式可帮助您使应用程序更易于管理和扩展。 It provides you facility to plug or unplug certain functionality with bare minimum changes and as well effecting application compatablity. 它为您提供了插入或拔出某些功能的工具,而只需进行最小的更改,即可影响应用程序的兼容性。
Generally when it comes to MVC Repository is used for Data Layer. 通常,谈到MVC,存储库用于数据层。
It is not neccessary to implement it but will be good if you do it and specific answer to your question it depends how you implement it as such one to one mapping of interface and class is not needed. 不一定要实现它,但是如果您执行它会很好,并且对问题的具体答案取决于您如何实现它,因为不需要接口和类的一对一映射。
You can go through following link for more details 您可以通过以下链接获取更多详细信息
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.