I have 3 tables. Table A, Table B and bridge Table AB. Table AB has a
unique id as well as foreign keys for Table A and Table B.

When creating new entires from each table and inserting I do the
following:

A a = new A();
B b = new B();
AB ab = new AB(){ A=a, B=b};

datacontext.AB.InsertOnSubmit(ab);
datacontext.SubmitChanges();

Doing this results in an error with the resulting generated SQL. The
entry cannot be inserted because the IDs of a and b have not resolved.
If instead I do:

A a = new A();
B b = new B();
datacontext.SubmitChanges();

AB ab = new AB(){ Aid=a.Aid, Bid=b.Bid};
datacontext.AB.InsertOnSubmit(ab);
datacontext.SubmitChanges();

Then all works fine but uses two submit changes calls. How is the
inserting suppose to be done using only one call to submit changes?

but get an error

-- 
You received this message because you are subscribed to the Google Groups 
"DbLinq" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/dblinq?hl=en.

Reply via email to