SubmitChanges(ConflictMode.ContinueOnConflict);
textBox1.Text = "Contacts modified successfully";
}
catch (ChangeConflictException ex)
{
foreach (ObjectChangeConflict oc in db.ChangeConflicts)
{
oc.Resolve(RefreshMode.KeepCurrentValues);
}
}
You also have at your disposal the MemberChangeConflict class that, when used with the ObjectChange-
Conflict class, enables you to iterate through the individual conflict members (database value/columns
that have been updated since the client application last accessed it).
foreach (ObjectChangeConflict oc in db.ChangeConflicts)
{
foreach(MemberChangeConflict mc in oc.MemberConflicts)
{
//
}
}
The MemberChangeConflict class gives you access to the original value, the current value, and the
database. For example:
mc.CurrentValue;
mc.OriginalValue;
mc.DatabaseValue;
With this information, you have all the data you need to effectively decide how you want to
handle conflicts.
266
Chapter 13: More about Entity Classes
Utilizing Transactions
LINQ to SQL supports three models of transactions:
??‘ Explicit local
??‘ Implicit
??‘ Explicit distributable
The difference between these types of transactions is how the transactions are created (explicitly or
implicitly) and what LINQ to SQL does with the call.
Pages:
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429