linq2sql beta: insert parent/child rows in one submitchanges

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
[email protected]
Posts: 27
Joined: Mon 08 Sep 2008 16:37

linq2sql beta: insert parent/child rows in one submitchanges

Post by [email protected] » 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.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Wed 15 Oct 2008 11:04

We are investigating this issue. You will be notified on the results as soon as possible.

[email protected]
Posts: 27
Joined: Mon 08 Sep 2008 16:37

workaround

Post by [email protected] » 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.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Wed 24 Dec 2008 17:21

The problem is fixed. Please try using the current version of dotConnect for MySQL.

Post Reply