code_junkie

Nested transactions in LINQ to SQL

Nov 11th, 2011
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. Dictionary<int, bool> opSucceeded = new Dictionary<int, bool> ();
  2.  
  3. for (int i = 0; i < 10; i++)
  4. {
  5. try
  6. {
  7. // this operation must be atomic
  8. Operation(dbContext, i);
  9.  
  10. // commit (?)
  11.  
  12. opSucceeded[i] = true;
  13. }
  14. catch
  15. {
  16. // ignore
  17. }
  18. }
  19.  
  20. try
  21. {
  22. // this operation must know which Operation(i) has succeeded;
  23. // it also must be atomic
  24. FinalOperation(dbContext, opSucceeded);
  25.  
  26. // commit all
  27. }
  28. catch
  29. {
  30. // rollback FinalOperation and operation(i) where opSucceeded[i] == true
  31. }
Add Comment
Please, Sign In to add comment