Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Is there a way to reference the parent of a Business Object?

0
Posted

Is there a way to reference the parent of a Business Object?

0

Yes. Objects have several types of parents possible. An individual Business Object may be one within a set of objects, it may be within another business object or it may be completely independent and owned by a Tform. The properties OwnerDataSet and Owner can be used to interpret who and what the parent is. The following code sample demonstrates how the TdmoContact object attempts to locate the Customer which it belongs to it tries three different approaches (1 Owner, 2 Information Cache, and finally creates a new object and populates from the database (slowest)). function TdmoContact.GetCustomer : TdmoCustomer; var aList : TosDataSet; begin // Perhaps this contact is an entry within a contactdataset of a // Customer object… if (OwnerDataSet is TdmoContactDataSet) and (TdmoContactDataSet(OwnerDataSet).Owner is TdmoCustomer) then begin Result := (TdmoContactDataSet(OwnerDataSet).Owner as TdmoCustomer); exit; end; // Now look in the cache… aList := CachedList(‘TdmoCustomerDataSetcmp’

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123