Page 1 of 1

linq2sql beta: insert parent/child rows in one submitchanges

Posted: 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/ShowPo ... 1&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.

Posted: Wed 15 Oct 2008 11:04
by Shalex
We are investigating this issue. You will be notified on the results as soon as possible.

workaround

Posted: 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.

Posted: Wed 24 Dec 2008 17:21
by Shalex
The problem is fixed. Please try using the current version of dotConnect for MySQL.