New Posts New Posts RSS Feed: Handling relationship between 2 models
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Handling relationship between 2 models

 Post Reply Post Reply
Author
kdev View Drop Down
Groupie
Groupie
Avatar

Joined: 03-Jan-2013
Posts: 83
Post Options Post Options   Quote kdev Quote  Post ReplyReply Direct Link To This Post Topic: Handling relationship between 2 models
    Posted: 12-Aug-2013 at 5:46am
Hi,

I have multiple models and wonder how to handle a Foreign key on entities shared among models.

Exemple :

Model A contains entity AA
Model B contains entity BB which has an interger property named AA_Id (it represent a relation to AA.Id)

When entity BB is saved, I want to call in my save interceptor a Service from model A which will generate an AA entity.
This AA entity will have a temporary Id, how can I do to update the AA_ID in my BB entity during the save ? 

Regards,

Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 12-Aug-2013 at 3:50pm
kdev,

Since DevForce does not support nested save calls, your scenario would not be possible.

An option would be if AA had a non-identity PK (i.e. a GUID), so you could create/add AA, assign the Guid to both AA and BB, and then call return base.ExecuteSave().
The advantage of this approach is that your save would be transactional across both models.



Edited by sbelini - 12-Aug-2013 at 3:51pm
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down