C#, OOD, and Database access with derived classes

Oct 18 2005 8:52 PM
Hello all, I apologize if this has been asked before but I have searched the internet for some time now and can't get a good answer with the search terms I put in so I'll ask it here.

Ok, so if I have a web app (or any app) that stores information into a database (SQL server, but irrelevant for this discussion).  Anyway let's say I structure my program like the following:

class Person
int PersonID
string First, Last, City, State, Zip

class Employee : Person
int Employee
DateTime HireDate

My question arises when you want to load an employee.  If you write a function that loads/grabs information from a database for class Person, do you call the 'base' function in the load/grab function for the Employee class?

Further explained:

Do I do a join query in the Employee class and simply pull all relevant data for the Employee class
ie.
select Employee.*, Person.* from Employee INNER JOIN Person ON Employee.PersonID = Person.PersonID

Doing a grab within a class for information relevant to that class seems better in my opinion for object oriented design, but I could see it taxing the database.  What is the proper way?