For Example consider a employee object which in turn contains
address objects (a collection object to hold residence address, office address
etc), a qualification object (again a collection to hold more than one
qualification). The ER model would contain seperate tables one for employee, one
for address and one for qualification and will be related through the primary
key of the employee table i.e EmployeeID. Under this context,
A. Is it possible to return the employee object containing
all associated collections as a single object with a single call to the database
? If yes how do achive it ?
B. If the employee object is bound to the UI controls through
csla datasource control - does the bound model/object retain changes made to the
data in the UI ? In particular assuming the address and qualification details
(being a collection) is bound to a data grid control, if user add further rows
or deletes existing row, will these changes also be reflected onto the model
that is bound to the control ?
I think CSLA handles both of these cases fine (and in fact is really designed to do exactly this).
Returning all the collections with a single database call is something of an implementation detail -- I can think of two ways, with the obvious mechanism being a stored procedure. (The less obvious way is what NHibernate does, populate root and child collection with a creative left join query).
Even if you don't populate the object in one database call, you can certainly do it in one round trip to the application server when you deploy in 3 or more tiers. You can make one call to the app server, make several database calls there, and then return the composite object. Lazy loading of the child objects and collections is another technique -- e.g. defer fetching until the first reference of the corresponding property. If you don't use the property, then the data is never fetched.
Also, yes the databinding will update your properly bound object as changes are made, including child row deletions/additions. CSLA's undo support will also let you roll back such changes multiple levels. The row deletions/additions aren't persisted until you actually save the object.
Copyright (c) Marimer LLC