InsertOnSubmit with SubmitChanges doing two inserts RRS feed

  • Question

  • I have a page that allows users to add new records and/or copy old records to new records. The issue is that when I call my Save method which does an InsertOnSubmit for the new records then calls SubmitChanges all records (parent table and child) are inserted twice. I checked and the InsertOnSubmit of the parent record is only called once as well as the SubmitChanges, and the child records never use the InsertOnSubmit they are simply added to the parent tables collection for the child table records. I don't know where to look for what is causing the duplicate records to be inserted. Can someone give me some ideas where to look?


    Tuesday, January 19, 2010 10:36 PM


  • DataContext instances have a GetChangeSet() method.  If you haven't already, put a breakpoint where you call SubmitChanges() and add dc.GetChangeSet() to a watch - that should identify what inserts are about to be made to the database.
    Thursday, January 21, 2010 2:43 PM