Print Page | Close Window

Handling relationship between 2 models

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2012
Forum Discription: For .NET 4.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=4266
Printed Date: 28-Apr-2025 at 5:10am


Topic: Handling relationship between 2 models
Posted By: kdev
Subject: Handling relationship between 2 models
Date 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,




Replies:
Posted By: sbelini
Date 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.




Print Page | Close Window