1

i had an error on a linq query when i tried to do SubmitChanges()

the problem is that what ever i try to do in my project now i'm getting the same error (i guess the linq still tring to do the Error Change)

how can i clean the pendding changes or deal with that issue otherwise?

Thanx!

Roy Amir
  • 457
  • 1
  • 6
  • 15
  • possible duplicate of [How can I reject all changes in a Linq to SQL's DataContext?](http://stackoverflow.com/questions/259219/how-can-i-reject-all-changes-in-a-linq-to-sqls-datacontext) – leppie Oct 28 '10 at 10:25

1 Answers1

0

You need to remove them from the 'queue'.

The simplest is just the call GetChanges, and do all the actions in reverse. Eg, Inserts becomes deletes, etc.

Here is an extension method I wrote that works for simple cases (modify it as you want).

leppie
  • 115,091
  • 17
  • 196
  • 297
  • i think it better to use: db.GetChangeSet().Updates.Clear() for updated, db.GetChangeSet().Inserts.Clear() for new or db.GetChangeSet().Deletes.Clear() for deleted items. Thansks! – Roy Amir Oct 28 '10 at 09:50
  • Well that would work, IFF it had a working clear method.... All those lists are readonly so it does not work in practice. – leppie Oct 28 '10 at 09:54