Matthais S.,
First, I would recommend using typed data sets for this sort of thing.
I would pass them through all layers of the application (front end,
business, data, etc, etc). They provide the heiarchical structure that you
want, easy binding capability, and all of the data classes will work with
them.
For the rest, see inline:
[color=blue]
> Now on to the questions:
> 1. Should each individual object be responsible of loading and saving it's
> data from and to the database or should the CompanyCollection take care of
> it (which IMHO seems a lot less coding to me on first sight)?[/color]
If you use the strongly typed data sets, then this shouldn't be an
issue. Generally though, I would say that this is based on the type of
relationship that you have between the objects. If the object is a owned by
the parent, then I would say that you should load it at the same time. If
it is just a relation, then I would say you could load it when needed. As
for saving, I would say having two routines is fine, as long as they are
both called within the same transaction scope (after all, a change in one
should imply a change in the other from a logical perspective, since the
relationship is one where the parent owns the child).
[color=blue]
>
> 2. Assumed the Collection takes care of the data-fetching, how should then
> the data changes whithin the individual objects be handled? What comes in
> mind is either a IsDirty property of each of the BusinessObjects (Company
> and AddresseInfo) (which can be checked by the collection) or an event
> (say DataChanged) to which the collection would hook up.[/color]
If you use typed data sets, you can use a DataView on them which will
allow you to see only the rows that are changed.
[color=blue]
>
> The problem I see with this approach is the following. Say my MDI GUI
> displays a list of all Companies in a TreeView on the lefthandside. On
> DoubleClick the selected BusinessObject gets displayed in a new "Document
> Window" which hosts a PropertyGrid control. Now my user opens 3 Companies
> and changes the data of all of them. How would I then handle the situation
> when he only wants to save to of those documents?[/color]
If each has it's own window, then they should require some sort of user
interaction to commit the changes. Until the user does that, you won't know
if they want to be saved or not. It doesn't really matter, until the user
saves the items.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mvp@spam.guard.caspershouse.com
[color=blue]
>
> Here is some additional information which I feel might be usefull:
>
> a. The amount of BusinessObject loaded from the Database is never really
> huge. Say a maximum of 2000 objects.
>
> b. BusinessObjects might contain collections of other BusinessObjects,
> e.g. the Company object will contain a EmployeeCollection.
>
> c. The amount of different BusinessObjects will probably not exceed 20.
>
> d. Performance issues are not a knock out criteria.
>
> e. The solution that I'm after is simple to code and maintain. I don't
> actually want to create a huge Framework with hundrets of classes which
> provide for unlimited scalability and the forth. We are talking about an
> application which is used by 10 people and new versions can be installed
> at any time if required.
>
> I hope someone can give me some advice on how to design this properly.
>
> Thanks in advance,
>
> Matthias[/color]