Saving changes to clild collection

Posts   
 
    
skhan
User
Posts: 15
Joined: 29-Mar-2011
# Posted on: 01-Apr-2011 22:31:42   

I am trying the follwoing

Dim prodMap As New MacPubvenprodmapEntity() With {.PubvenprodId = Guid.NewGuid(), .PubvenId = selectedMap.PubvenId, .ProdId = selectedAddProduct.ProdId, .ProdName = selectedAddProduct.ProdName } selectedMap.MacPubvenprodmaps().Add(prodMap) selectedMap.Save()

But the changes are nor being saved in the DB. There is a FK relationship between selectedMap and MacPubvenprodmapEntity.

The following works

Dim prodMap As New MacPubvenprodmapEntity() With {.PubvenprodId = Guid.NewGuid(), .PubvenId = selectedMap.PubvenId, .ProdId = selectedAddProduct.ProdId, .ProdName = selectedAddProduct.ProdName } prodMap.Save()

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 02-Apr-2011 04:36:26   

What is the difference between both codes? What is selectedMap.MacPubvenprodmaps() ? What LLBLGen version are you using?

David Elizondo | LLBLGen Support Team
skhan
User
Posts: 15
Joined: 29-Mar-2011
# Posted on: 02-Apr-2011 08:43:12   

The first set of code...I am trying to add items to the collection of the selectedMap and then try to save selectedMap and have it save the items in the collection...similar situation to an Order and OrderItems.....I am adding items to the order and then when I save the order entity it automatically saves the items.

daelmo wrote:

What is the difference between both codes? What is selectedMap.MacPubvenprodmaps() ? What LLBLGen version are you using?

skhan
User
Posts: 15
Joined: 29-Mar-2011
# Posted on: 03-Apr-2011 02:15:16   

Got it to work by

prodMap.Save(True)

"When true, it will save all dirty objects referenced (directly or indirectly) by this entity also."

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 03-Apr-2011 19:53:25   

Oh, yeah, recursively save simple_smile Good you got it working.

David Elizondo | LLBLGen Support Team