通用类的CRUD操作在asp.net使用C# [英] generic class for CRUD operations in asp.net Using C#

查看:108
本文介绍了通用类的CRUD操作在asp.net使用C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Asp.net初学者使用C#和Web表单中的大部分工作,大部分的时间,当我做任务,我重复同样的code一遍又一遍在不同的类,例如,用于插入数据,我必须为每一个具体形式右侧插入功能。我要的是有当这些方法插入,删除,选择和被选择更新定义的一般通用类,我只需要举例说明这些对象在哪里,通过参数对这些对象提交表单和传递数据。在PHP中,我们把它叫做dbClass,我不知道它在什么asp.net调用,它基本上是一个单一的类在发生在应用程序中每个CRUD操作被利用。这将是pciated如果有人能帮助我非常AP $ P $。
在此先感谢

I am a beginner at Asp.net using C# and worked mostly in web forms, most of the time when i do tasks, i repeat the same code over and over at different classes, for example, for inserting data, i have to right insert functionality for every specific form. What i want is to have a generic class where these methods for Insertion, deletion, selection, and updation are defined generically and i only have to instantiate these objects where i submit forms and pass data through parameters to these objects. In Php, we called it a dbClass, i dont know what its called in asp.net, its basically a single class being utilized at every crud operation taking place in the application. It would be highly appreciated if someone can help me. Thanks in advance

推荐答案

我建议你使用ORM喜欢的实体框架和(<一个href=\"http://2guysfrommumbai.word$p$pss.com/2013/02/02/entity-framework-generic-repository-pattern-part-1/\"相对=nofollow>通用) Repository模式。我相信一定会满足您的需求,并会帮助你执行 DRY原则

I would recommend you using an ORM like Entity Framework and the (Generic) Repository Pattern. I believe that will suit your needs and will help you enforce the DRY principle.

此外,如果你使用ASP.NET Web窗体4.5,你应该看一看新的模型绑定功能。

In addition, if you're using ASP.NET Web Forms 4.5 you should take a look at the new Model Binding feature.

这篇关于通用类的CRUD操作在asp.net使用C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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