linq2sql beta: insert parent/child rows in one submitchanges

linq2sql beta: insert parent/child rows in one submitchanges

Postby yuri@wallie.com » Tue 14 Oct 2008 12:40

Hi,

I've tried to insert parent and child rows in one db.submitchanges(), the childobject has a foreign key relationship to the parentobject

Like this:

Code: Select all
ParentObject po = new ParentObject();

ChildObject co = new ChildObject();

po.Childobjects.add(co);

db.ParentObjects.insertOnSubmit(po);
db.SubmitChanges();


As described here : http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2472691&SiteID=1

But that doesnt't work, i cannot add a childobject to a parentobject.

My workaround at the moment is the following:

Code: Select all
childobject.insertonsubmit(co);
parentobject.insertonsubmit(po);
db.submitchanges();


It is important to add the childobject first, otherwise a FK relationship error is thrown.
yuri@wallie.com
 
Posts: 27
Joined: Mon 08 Sep 2008 16:37

Postby Shalex » Wed 15 Oct 2008 11:04

We are investigating this issue. You will be notified on the results as soon as possible.
Shalex
Devart Team
 
Posts: 7833
Joined: Thu 14 Aug 2008 12:44

workaround

Postby yuri@wallie.com » Fri 17 Oct 2008 10:05

The workaround i mentioned does not work

I currently am using two submitchanges() to insert parent and child records, ofcourse not a good thing because it all should be done in one transaction.
yuri@wallie.com
 
Posts: 27
Joined: Mon 08 Sep 2008 16:37

Postby Shalex » Wed 24 Dec 2008 17:21

The problem is fixed. Please try using the current version of dotConnect for MySQL.
Shalex
Devart Team
 
Posts: 7833
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for MySQL