New Posts New Posts RSS Feed: Saving many-to-many relationship
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Saving many-to-many relationship

 Post Reply Post Reply
Author
CJBriers View Drop Down
Newbie
Newbie
Avatar

Joined: 20-Jul-2011
Posts: 5
Post Options Post Options   Quote CJBriers Quote  Post ReplyReply Direct Link To This Post Topic: Saving many-to-many relationship
    Posted: 22-Jul-2011 at 7:38am
Let's say we have a many-to-many relationship between Person and Pet entities (with no payload).  When adding an existing Pet entity to a Person and saving the Person entity:

aPerson.Pets.Add(aPet);
EM.Instance.SaveChangesAsync(new [] {aPerson}); //we're using singleton pattern

This causes a duplicate (same data, different ID) aPet entity to be saved to the DB.  

However, if I do this:

aPerson.Pets.Add(aPet);
EM.Instance.SaveChangesAsync(); 

No duplicate entry is saved to the DB.  Due to the nature of our application, I really prefer saving only the aPerson entity and not the Pet entities. Any way to do this?


Edited by CJBriers - 03-Aug-2011 at 6:48am
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: 22-Jul-2011 at 8:39am
Hi CJBriers,

This is a bug that has been fixed.

DevForce 6.1.2 will have the fix and will be available early in August.

Silvio.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down