如何使用我的模型表创建存储库? [英] How to create a Repository with a table of my model?

查看:109
本文介绍了如何使用我的模型表创建存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用批量编辑的Telerik MVC扩展的网格基础,但我不知道如何在我的数据库表上创建存储库,而不是在名为EditableProduct的示例中使用的类。有一个基于Telerik Demos的EditableProduct的示例 http://demos.telerik.com/ aspnet-mvc / razor / grid / editingbatch?theme = hay



我如何根据数据库SQL Server 2008的表创建存储库?实际上我可以使用没有Telerik扩展名的View更新此表。

解决方案

存储库模式是最常见的设计模式之一用于数据访问层。这为底层数据库提供了抽象。当数据库尚未就绪并且我们想要通过构建存根来测试应用程序时,这也很有用。 

因此,存储库模式提供可测试性,abstration和依赖注入。





请浏览你获得的链接清楚地了解存储库模式以及如何在MVC项目中实现这一点

http://www.expertbloggingon.net/post/2011/11/23/CSharp-Repository-Pattern-Design-Patterns-in-Action.aspx



http://blog.lowendahl.net/?p= 249





注意:您可以在没有存储库模式的情况下强制执行telerik的所有CRUD功能。& amp; lt ; /预&放大器;放大器; GT;&安培; LT /预&安培; GT;< /预>


I have a grid base on Telerik MVC extensions using batch edit, but I don''t know how create the Repository base on a table of my database instead of the class used in the example named EditableProduct. There are the example based on EditableProduct from Telerik Demos http://demos.telerik.com/aspnet-mvc/razor/grid/editingbatch?theme=hay

How I can create the Repository based on a table of my database SQL server 2008? Actually I can updated this table using a View without Telerik extension.

解决方案

Repository pattern is one of the design pattern which is most frequently used in Data access layer. This provides an abstraction to underlying database. This is also useful when database is not ready and we want to test the application by building an stub.

So repository pattern provides testability, abstration and  dependency injection.



Please go through the link you get a clear idea about the repository pattern and how to implement this in your MVC project
http://www.expertbloggingon.net/post/2011/11/23/CSharp-Repository-Pattern-Design-Patterns-in-Action.aspx

http://blog.lowendahl.net/?p=249


Note: You can impement all the CRUD functionalities for the telerik without Repository pattern.&amp;lt;/pre&amp;gt;&lt;/pre&gt;</pre>


这篇关于如何使用我的模型表创建存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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