Objects how to.

hog

Senior Contributor
Joined
Mar 17, 2003
Messages
984
Location
UK
I hope I can explain this so as to make it clear what I'm trying to get my head around?

Lets say I have three objects, A, B & C all of which get their data from three different tables, tblA, tblB & tblC.

Right so now I need to create an end object that inherits all 3. So A inherits B which inherits C and finally D inherits A. I therefore endup with an object which can be populated with data from 3 different tables.

What I'm trying to get my head around is this.

Say I want to save changes using the D objects Save method which will need to save the changes to tblA, tblB and tblC respectively.

What happens if when the save gets to tblC and the concurrency stops the update as some other user beat me to it?

This will stop an invalid update to tblC but tblA and tblB would have already been updated?

Does this make sense?

Please ask for more clarification if require:(?
 
I don't think you want inheritance if I understand what you want.

If you have 3 objects, A B and C, and each holds the data (and presumably methods) for a single table, I would think you'd want object D to have member variables for each of the 3 classes. So class D might look like (simplified):
C#:
public class D
{
    private ClassA myA;
    private ClassB myB;
    private ClassC myC;
}

You might expose them as public, or only allow certain methods of each object to get called. To do that, you'd create methods in D that have the same name and params as a method in A B or C and just call the method in A B or C. That way you can limit what methods or properties you want to expose.

To implement a save in D, it would simply call Save on myA, myB, and myC.

-Nerseus
 
Ok thanks, that makes sense but what of the save problem? Say saveA and saveB go ok but saveC gets refused due to conflict. Would I need to use some form of transaction method and if so is this something I need to create manually to ensure integrity throughout A,B and C.
 
Back
Top