
Signature
___________
best regards
Poly
> > Do you really have to keep going with your half-working data?
>
> If i can not delete an item i need only to show message about it and to
> continue working.
In that case, I'm afraid you need someone with more LINQ to SQL
experience than me :(

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
> > Do you really have to keep going with your half-working data?
>
> If i can not delete an item i need only to show message about it and
> to continue working.
The problem with Linq to Sql's context is that it is an entire unit
of work. This means that all entities which are 'dirty' (== changed or
new), or marked for deletion will be persisted in 1 transaction when
you say SubmitChanges. If one of those entities fails, you'll run into
the problem that the whole transaction has to roll back.
With the GetChangeSet method you get the list of entities which are
dirty or otherwise involved in the transaction.
I don't know if Linq to Sql throws an exception which contains the
entity which was involved, but the exception might be helpful in fixing
the issue.
The entity which caused the transaction to fail has to be removed from
the context, otherwise you'll never make it work.
FB

Signature
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Markus Springweiler - 20 Mar 2008 12:12 GMT
Frans,
> I don't know if Linq to Sql throws an exception which contains the
> entity which was involved, but the exception might be helpful in fixing
> the issue.
When you use
SubmitChanges(ConflictMode.ContinueOnConflict);
then you can query all conflicts via the DataContext property
"ChangeConflicts".
> The entity which caused the transaction to fail has to be removed from
> the context, otherwise you'll never make it work.
Each member of the ChangeConflicts collection (type ObjectChangeConflict)
contains lots of data why it failed and also a method "Resolve" for
reloading from database and an overload which helps with rows which where
deleted in the database meanwhile.

Signature
/\/\arkus.