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();
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();