Hi,
I have an ASP.NET MVC application that uses LINQ2SQL as the database layer. I can save data back to the database no problem but I've came across a few issues when trying to save using a wizard-type scenario where data is collected over a few different forms but not saved to the database until the last form "Save" button is clicked.
At first I tried adding new objects to the datacontext, using InsertOnSubmit() or DeleteOnSubmit() and on the final page using SubmitChanges() to commit to the database. The problem with this is that if I tried to DeleteOnSubmit() an object that hadn't been submitted yet I would get an error.
I got round it eventually by writing a lot of code to manage the state of each object (insert, update or delete) and then on the final submit I make all changes to the DataContext before saving.
I'm wondering if there is a better way of managing the state of objects across pages using LINQ2SQL or if the manual code is the best way round it?