Click here to Skip to main content
15,906,645 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Updated 23-Jun-10 13:55pm
v2

1 solution

"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).
 
Share this answer
 
Comments
Batul Saifee 24-Jun-10 16:02pm    
Thanks..... I just wanted an opinion to make sure what I am thinking is truly correct. Thanks a lot for the confirmation.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900