So, I'm trying to make a transaction with LINQ to SQL. I read that if I use SubmitChanges(), it would create a transaction and execute everything and in case of an exception everything would be rolled back. Do I need to use MULTIPLE SubmitChanges()? I'm using something like this code and it isn't working because it isn't saving any data on the first table.. (I need it's ID for the children table).
If I do use another SubmitChanges() right after the first InsertOnSubmit doesn't it lose the idea of a transaction?
myDataContext db = new myDataContext();
Process openProcess = new Process();
openProcess.Creation = DateTime.Now;
openProcess.Number = pNumber;
//Set to insert
db.Process.InsertOnSubmit(openProcess);
Product product = new Product();
product.Code = pCode;
product.Name = pName;
product.Process_Id = openProcess.Id;
//Submit all changes at once?
db.SubmitChanges();