ASP.NET TableAdapter更新-如何工作? [英] ASP.NET TableAdapter Update - How does it work?

查看:49
本文介绍了ASP.NET TableAdapter更新-如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将网站建设为学校项目,该网站使用ASP.NET Web服务.我正在Web服务中实现DAL,BLL结构.如大多数文章中所述,tableAdapter自动生成更新方法(已选择该选项).在BLL中,我有一个名为UpdateInformation的函数,该函数依次调用tableAdapter.Update().我想知道TableAdapter.Update()方法实际上是如何执行的?更准确地说,如果用户仅更新了其中一个字段,那么update方法是否仍会更新数据库中的所有字段?还是仅更新已更改的字段足够聪明?
如果无论如何都更新所有字段,那么我的教授建议对每个字段进行单独的更新.那可行吗?

我正在尝试使设计尽可能的好,因为一旦我毕业,其他人将继续进行该项目.

I am building a website as a school project, which uses ASP.NET webservice. I am implementing the DAL, BLL structure in my webservice. As mentioned in most of the articles, the tableAdapter automatically generates the update method (the option is selected). In the BLL, I have a function called UpdateInformation , which in turn calls the tableAdapter.Update(). I want to know how does the TableAdapter.Update() method actually execute? To be more precise, if the user has updated only say 1 of the fields, does the update method still update all of the fields in the database? Or is it smart enough to only update the fields that have been changed?
If it is updating all fields no matter what, then my professor has suggested making individual updates for each field. Is that feasible?

I am trying to make the design as good as possible, as someone else will be continuing with this project once I graduate.

推荐答案

越好".

为每个字段制定更新方法不是一个好的设计.您的教授很显然会根据直觉和CPU不足的旧系统进行过早的优化.

通过仅使用一种更新方法,设计在所有情况下都保持简单直观(程序员不必担心要更改哪个字段以及何时更改,只需设置值并调用Update).另外,考虑一下您更改了五个字段后的情况.这将产生五个UPDATE,并且对数据库服务器造成了很大的压力(相比之下,只有一个较大的UPDATE).

甚至NHibernate都会更新所有字段,无论发生了什么更改(尽管可以更改,但这会使速度变慢).
"I am trying to make the design as good as possible".

Making update methods for every field is not a good design. Your professor is cleary making premature optimizations based on intuition and old systems with inadequate CPU power.

By using only one update method the design stays simple and intuitive in all situations (the programmer doesn''t have to worry about thinking what field has changed and when, just set the values and call Update). Also, think about the situation when you have changed, say, five fields. That makes five UPDATE''s and is quite a stress on the database server (compared to only one, a bit larger UPDATE).

Even the NHibernate updates all field regardless of what has changed (this can be changed, though, but it makes it slower).


这篇关于ASP.NET TableAdapter更新-如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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