必须使用Repository模式 [英] Mandatory to use Repository pattern

查看:106
本文介绍了必须使用Repository模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI朋友,



我是MVC 3的新手,意思是在实现存储库模式时,

我发现存储库模式在视图和业务逻辑层之间创建抽象层,



但我的问题是,是否必须实现存储库模式,如果是,则为什么。



是否有任何其他模式可用于制作抽象层。



请建议我实际使用存储库模式。



谢谢

HI friends,

I am new with MVC 3,mean while implementing the repository pattern,
I found that the repository pattern make the abstraction layer between the view and the bussiness logic layer,

But my quesction here is,Is it mandatory to implement the repository pattern,If yes then why.

Are any other patterns avalible to make abstraction layer.

Please suggest me the actual use of repository pattern.

Thanks

推荐答案

没有。存储库模式不是必需的。



但它在复杂项目中非常有用和/或如果你想使用单元测试。阅读这篇文章: http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-the-repository-and-unit-工作模式在asp-net-mvc-application [ ^ ]



但它不在视图和BL之间,而是在数据模型和控制器之间。它不仅是(不是真的?)一个抽象层,它是一种将逻辑与数据分开的方法,因此您可以轻松地更改数据源 - 例如在模拟场景中。
No. Repository pattern is not mandatory.

But it is really useful in complex projects and/or if you want to use unit testing. Read this article: http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-the-repository-and-unit-of-work-patterns-in-an-asp-net-mvc-application[^]

But it is not between the view and the BL, it is between the data model and the controller. And it is not only (not really?) an abstraction layer, it is a way to separate the logic from the data, so you can change the data source easily - for example in a mocking scenario.


这篇关于必须使用Repository模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆