On Mon, Oct 25, 2010 at 6:38 AM, Rifky Rafeethu <[email protected]> wrote: > hi guys, > > i'm a vb.net developer having a bit experience but new to OOP. i'm having > some doubts such as How to load data to objects using OOP concept when there > is a relationship to another object. i searched in googled and every one is > telling to load the primary object only at initial and load the related > objects when only necessary. > > for example the employee object is related to branch object. each branch can > have many employees but employee can have only one branch. so Employee > object is related to branch object in One to Many relationship. say for > example we load the employee detail, we only load the employee details at > first then if we need to excess the branch only (such as > Employee.Branch.BranchName) we need to load the branch details. > > so my issue is how to load Data into objects using vb.net for the above > example from SQL server database. ------------------------------------------------
Employee : Branch Do you want to load a single Employee and it's Branch data or are you more interested in the Branch to Employees relationship that has all Emps for a given branch? To do this via OOP You need to identify the Data Select clause to pass back to the backend. Pass that indicator and parameter(s) to the data access class. The DAC, data access class doesn't know WHAT to get only HOW to get data. It can return a simple row, a table a dataset, XML, or data objects. The explanation of the Q makes me see XML <data> <branch id=2655> <employee id=E5F97EBC-1344-4919-9C4E-F36330397183> </employee> <employee id=706F6656-F632-4E08-BD70-3217F937E353> </employee> <employee id=???? > </employee> </branch> </data> This one confuses me from a collection POV: Employee.Branch.BranchName Did you mean: Employee.Branch-->Branch.BranchName Branch = 1 row. Employee = N row(s) -- Stephen Russell Sr. Production Systems Programmer CIMSgts 901.246-0159 cell
