Changeset 6267 for branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/TransactionManager.cs
- Timestamp:
- 05/24/11 16:55:48 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/TransactionManager.cs
r5708 r6267 1 1 using System; 2 2 using System.Transactions; 3 using HeuristicLab.Services.Hive.Common;4 3 5 4 namespace HeuristicLab.Services.Hive.DataAccess { 6 5 public class TransactionManager { 7 public void UseTransaction(Action call ) {8 TransactionScope transaction = CreateTransaction();6 public void UseTransaction(Action call, bool serializable = false) { 7 TransactionScope transaction = serializable ? CreateSerializableTransaction() : CreateTransaction(); 9 8 try { 10 9 call(); … … 16 15 } 17 16 18 public T UseTransaction<T>(Func<T> call ) {19 TransactionScope transaction = CreateTransaction();17 public T UseTransaction<T>(Func<T> call, bool serializable = false) { 18 TransactionScope transaction = serializable ? CreateSerializableTransaction() : CreateTransaction(); 20 19 try { 21 20 T result = call(); … … 29 28 30 29 private static TransactionScope CreateTransaction() { 31 return new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = ApplicationConstants.IsolationLevelScope }); 30 return new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.ReadUncommitted }); 31 } 32 private static TransactionScope CreateSerializableTransaction() { 33 return new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.Serializable }); 32 34 } 33 35 }
Note: See TracChangeset
for help on using the changeset viewer.