How do you clear changes in LinqToSql?

前端 未结 2 1621
一生所求
一生所求 2021-01-22 18:48

I have a combobox in my WPF app that is databound to my list of objects in my View Model. When the user makes changes to the selected object and then selects another item befor

2条回答
  •  离开以前
    2021-01-22 19:16

    As well as using Marc's approach using DeleteOnSubmit (or DeleteAllOnSubmit) to remove the inserts, the following will actually undo any updates aswell:

    // clears any updates.  
    ChangeSet changes = dataContext.GetChangeSet();
    dataContext.Refresh(RefreshMode.OverwriteCurrentValues, changes.Updates);   
    

提交回复
热议问题