Click here to Skip to main content
15,905,238 members
Home / Discussions / C#
   

C#

 
QuestionVideo streaming Pin
resna.s27-Nov-08 22:11
resna.s27-Nov-08 22:11 
AnswerRe: Video streaming Pin
Simon P Stevens27-Nov-08 23:01
Simon P Stevens27-Nov-08 23:01 
AnswerRe: Video streaming Pin
Tom Deketelaere27-Nov-08 23:20
professionalTom Deketelaere27-Nov-08 23:20 
AnswerRe: Video streaming Pin
Pete O'Hanlon28-Nov-08 2:54
mvePete O'Hanlon28-Nov-08 2:54 
Question3tier - dataflow Pin
jogisarge27-Nov-08 21:28
jogisarge27-Nov-08 21:28 
AnswerRe: 3tier - dataflow Pin
Thomas Weller27-Nov-08 22:05
Thomas Weller27-Nov-08 22:05 
GeneralRe: 3tier - dataflow Pin
jogisarge28-Nov-08 9:05
jogisarge28-Nov-08 9:05 
GeneralRe: 3tier - dataflow Pin
Thomas Weller28-Nov-08 18:32
Thomas Weller28-Nov-08 18:32 
Well, I assume that your grid and your Customer instances are automatically kept in sync all the time (you can achieve this by simply databinding your Customers collection to the grid - each property to its respective column). So it's a matter of how to persist the changed/new/deleted Customer instances from the BL to the db.

The DAL is responsible for updating/creating/deleting Customers, the BL has to maintain the necessary information. There are two approaches to the question How is the necessary information hold?: (1) It can be stored in the business object itself or (2) the Repository can maintain respective lists. In the first case the business objects would have each a Dirty and a Deleted property (New can normally be seen from the fact that new objects have no ID yet...), in the second the respective repository would maintain lists of changed/new/deleted objects. The second approach is the cleaner one, since in this case the business objects do not expose persistence related stuff at all. It's also faster, if you have to manage very large lists.

So, in our example, it would go like this:

The user changes sth. in the grid, e.g. a Customers firstname from 'John' to 'Mike'.
This changes the related Customer instances Firstname property respectively. Inside this property setter, either an internal Dirty-Flag is set to true (1) or the Customer instance tells its Repository that it has been changed (2).
Now the User clicks on the Save button, which would result in a call to CustomerRepository.SaveAll or sth. similar. SaveAll would cause the repository to go through the list of Customers and save/delete/create all as indicated by their respective properties (1), or the repository would ask its own internal lists to do this (2). The repository then calls the DAL to do the persistence stuff, wrapped inside a db transaction.

Regardless of the exact implementation details, the UI simply calls SaveAll, and that's it. It is totally agnostic of what goes on behind the scenes.

(Often, an object-relational mapper (like e.g. NHibernate or MS Entity Framework, to name just two) is used to automate all this persistence stuff like keeping DB and BL in sync, caching etc. Admittedly, it's a bit complicated to learn, but it pays. This article on CP might give you a good overall picture, if you are willing to invest some time and effort: NHibernate Best Practices with ASP.NET, 1.2nd Ed.[^])

Regards
Thomas

www.thomas-weller.de

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Programmer - an organism that turns coffee into software.


QuestionHow to log msg in Remote machine event log... Pin
Chintan.Desai27-Nov-08 20:11
Chintan.Desai27-Nov-08 20:11 
AnswerRe: How to log msg in Remote machine event log... Pin
Abhijit Jana27-Nov-08 20:38
professionalAbhijit Jana27-Nov-08 20:38 
Questionhow to cast combobox Pin
sadara27-Nov-08 20:01
sadara27-Nov-08 20:01 
QuestionRemoting Unit Testing suggestions. Pin
Member 232448327-Nov-08 19:48
Member 232448327-Nov-08 19:48 
QuestionInternal buffer(I/O) size of serialport Pin
Shivarudrayya H27-Nov-08 18:00
Shivarudrayya H27-Nov-08 18:00 
AnswerRe: Internal buffer(I/O) size of serialport Pin
Mbah Dhaim27-Nov-08 19:43
Mbah Dhaim27-Nov-08 19:43 
Questioncreating ssis package on the fly using C# Pin
l.laxmikant27-Nov-08 17:43
l.laxmikant27-Nov-08 17:43 
Question[HELP] Attempted to access an element as a type incompatible with the array Pin
dnlmarshall27-Nov-08 15:38
dnlmarshall27-Nov-08 15:38 
AnswerRe: [HELP] Attempted to access an element as a type incompatible with the array Pin
Christian Graus27-Nov-08 15:40
protectorChristian Graus27-Nov-08 15:40 
GeneralRe: [HELP] Attempted to access an element as a type incompatible with the array Pin
dnlmarshall27-Nov-08 15:46
dnlmarshall27-Nov-08 15:46 
GeneralRe: [HELP] Attempted to access an element as a type incompatible with the array Pin
Christian Graus27-Nov-08 15:55
protectorChristian Graus27-Nov-08 15:55 
GeneralRe: [HELP] Attempted to access an element as a type incompatible with the array Pin
dnlmarshall27-Nov-08 16:04
dnlmarshall27-Nov-08 16:04 
QuestionCAS problem Pin
_anil_27-Nov-08 14:18
_anil_27-Nov-08 14:18 
AnswerRe: CAS problem Pin
V.27-Nov-08 20:25
professionalV.27-Nov-08 20:25 
Questionhow to record sound from a mic Pin
BahaaHany27-Nov-08 11:39
BahaaHany27-Nov-08 11:39 
AnswerRe: how to record sound from a mic Pin
Shyam Bharath27-Nov-08 18:34
Shyam Bharath27-Nov-08 18:34 
GeneralRe: how to record sound from a mic Pin
BahaaHany27-Nov-08 20:57
BahaaHany27-Nov-08 20:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.