views:

11

answers:

2

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!

A: 

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
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
Well that would work, IFF it had a working clear method.... All those lists are readonly so it does not work in practice.
leppie
A: 

use: db.GetChangeSet().Updates.Clear() for updated, db.GetChangeSet().Inserts.Clear() for new or db.GetChangeSet().Deletes.Clear() for deleted items

for more info: Click

Roy Amir
I already told you, Clear does not work. It will throw an exception. Please try it.
leppie