Parent -> Child <- Parent Relationship
 
Home My Account Forum Try It! Buy It!
About Contact Us Site Map
StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      



Parent -> Child <- Parent RelationshipExpand / Collapse
Author
Message
Posted 02/05/2008 8:34:28 AM


StrataFrame Novice

StrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame Novice

Group: Forum Members
Last Login: 06/19/2008 11:16:33 AM
Posts: 73, Visits: 12,471
Howdy everyone:

I have an address design that factors out the actual address information into a separate table (CCAddress) and links this address to the appropriate entity (either a Company or a Salesman) via a foreign key relationship.  In essence the following

CCCompany.comp_pk

                                  CCAddrLink.adlk_comp_pk

                                  CCAddrLink.adlk_addr_pk                   CCAddress.addr_pk

                                  CCAddrLink.adlk_agnt_pk

CCSalesAgent.agnt_pk

The parent child relationship setup at design time is as follows:

CCSalesAgent.agnt_pk -> CCAddrLink.adlk_agnt_pk and when it runs CCSalesAgent is the parent business object of CCAddrLink

The default values for CCAddrLink.adlk_agnt_pk and CCAddrLink.adlk_comp_pk is set to null through the use of a nullable type (set in the BOMapper).  When a new record is added I simply set these to properties to NULL.  This is necessary since either one or the other FK must be null (only one address can apply to another entity, not two ... the null value in the unused FK field prevents the DRI from triggering).

The question is this, when I call the oAddressLink.Save() method the framework should automatically link the parent and the PushDataToChildren() method in the business layer, unfortunately, this is not happening and I was forced to manually update the links and wrap it all in a transaction ... not a big deal but I'd prefer not to do that.

My question is this, does prepopulating the foreign keys with null values prior to calling the save stop the framework from pushing primary keys to children ... I don't think it should but does it?

Thanks,

CT

Post #14000
Posted 02/05/2008 9:20:21 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 8:47:41 AM
Posts: 4,104, Visits: 4,175
The only reason that this would not work like any other BO is if the ParentBusinessObject property is not set and a parent relationship not defined.  As you know, the BO will propagate the parent's newly created PK to the children....BUT, if you are pre-populating the child records with a NULL value, then the parent doesn't know what the child record would be.  For example, if you setup the ParentBusinessObject property and create a new child record, the child will immediately (upon creation of the new record) update that relationship field with the value of the parent foreign key.  In this instance, when the save occurs the parent knows how to update the child record with the new "official" primary key since it knew what the temp PK was within the BO.  But if you override this with NULLs then the parent will not be able to sync back with the child records.
Post #14001
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Ben Chase, Trent L. Taylor, Steve L. Taylor

PermissionsExpand / Collapse

All times are GMT -6:00, Time now is 10:29am

Powered By InstantForum.NET v4.1.4 © 2008
Execution: 0.062. 9 queries. Compression Enabled.
Site Map - Home - My Account - Forum - About Us - Contact Us - Try It - Buy It

Microsoft, Visual Studio, and the Visual Studio logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.