Here is my problem,
I want to get the ID from what I just inserted and use it as a foreign key for another table.
Records record = new Records {
field1 = 1;
field2 = 2;
};
DataContext.Records.InsertOnSubmit(record);
DataContext.SubmitChanges(); // transaction 1
int recordID = record.ID;
tblDEMO demo = new tblDEMO {
rID = recordID
field1 = 1;
};
DataContext.tblDEMOs.InsertOnSubmit(demo);
sparxdc.SubmitChanges(); // transaction 2
My question is, If I do this it will create 2 transactions. How can I rollback the 1st one if the 2nd is fail??
If you are ok with both submits within one transaction: