inserting Fk of related identity Pk

Posts   
 
    
chaimweb
User
Posts: 10
Joined: 12-Apr-2005
# Posted on: 05-Sep-2005 13:52:03   

Does the generated code "know" to insert the returned Pk of an entity where the Pk is defned as an Identity field into the related entities' fk fields? Example: When entering a new order, the returned Pk is eg. 560 - will the code insert this value - 560 - into the related child records of the OrderDetails Enties?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 05-Sep-2005 15:25:26   

Yes, as long as you've added the orderdetail entities to the order 's OrderDetails collection, so they're related in memory. When you save the order recursively, all entities are saved in 1 transaction, and pk/fk's are synced automatically.

Frans Bouma | Lead developer LLBLGen Pro
chaimweb
User
Posts: 10
Joined: 12-Apr-2005
# Posted on: 05-Sep-2005 16:03:34   

Does it also work in a 1:1 Pk->Fk relation ?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 05-Sep-2005 16:54:32   

chaimweb wrote:

Does it also work in a 1:1 Pk->Fk relation ?

Yes. It only doesn't sync in the situation: PK 1:1 PK (fk side), and the FK side is NOT new. This is logical, as the PK of a non-new entity can't be set/shouldn't be set.

Frans Bouma | Lead developer LLBLGen Pro