Valnuke (9) [Avatar] Offline
Hi, I have a problem and I can't seem to solve it

Using scope As New Transactions.TransactionScope
Catch ex As Exception
End Try
End Using

Let's say that I receive an error and I can't delete the shipmentToDelete from database. (maybe because its ID is used as FK in another table)

Even if I solve the problem, my datacontext still has these 2 object in the GetChangeSet.Deletes cache!!
so every time i try to do db.submit, for whatsoever reason, I get the same error

how to avoid it?

I would like to be able to clear somehow the db pending object cache in case of errors, otherwise I would have to create a new datacontext object, but I'm worried this could give problems the rest of my Windows Form...

fabrice.marguerie (224) [Avatar] Offline
Re: Big problem with db.deleteonsubmit
I believe that this follows that Unit of Work pattern that Microsoft used when designing LINQ to SQL's DataContext class.
This means that if you want to go on with the processing that failed, you can retry with the same DataContext, but if you want to submit something different, then this is considered a new Unit of Work and you have to create a new DataContext.
I don't know if there are ways to get around this and follow another approach.