I have a problem with Linq to SQL InsertOnSubmit, which only seems to work for the first item in a table.
For example with the following:
var noteDetail1 = new NoteDetail() { Title = "Test Note Title 1", NoteText = "Test note" };
var waiverDetail1 = new WaiverDetail() { Title = "Test Waiver Title 1", NoteText = "Test waiver details text" };
var riskDetail1 = new RiskDetail() { Title = "Test Risk Title 1", NoteText = "Test risk details text" };
context.Notes.InsertOnSubmit(noteDetail1);
context.Notes.InsertOnSubmit(riskDetail1);
context.Notes.InsertOnSubmit(waiverDetail1);
context.SubmitChanges();
I only get the first entity ("Test Note Title 1") inserted into the database. If I place a SubmitChanges after each InsertOnSubmit, all the rows are successfully inserted.
The above Types are all inherited from a Note class, so are inserted into the same table.
I am, however, experiencing the same problem with non-derived classes.
I've spent a long time looking at this but can't find what I've done wrong. The whole idea of InsertOnSubmit/SubmitChanges is so that you can do multiple changes so there must be something simple I am missing.