Your question *does* sound more like an ORM question but I think I get the basic conundrum you are trying to convey.
The advice to load the secondary objects on demand is very valid and wise. With relevance to your example, I would expect to load an Employee object that possesses a reference to the Branch object. However, the Branch object does not load all it's data upon construction. The non-essential details of a Branch are loaded only on demand (via a public method, for example). Essential details (such as those that could form a foreign key in the Employee table, e.g. BranchID) are loaded at construction itself. On Oct 25, 4:38 pm, 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. > > any sample coding will be highly helpful as i couldn't find any proper doc > in the web.. > > waiting for a answer.. > > thanks and regards > Rifky
