IsolationLevelExtensions.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233
  1. using System.Data;
  2. namespace Abp.Transactions.Extensions
  3. {
  4. public static class IsolationLevelExtensions
  5. {
  6. /// <summary>
  7. /// Converts <see cref="System.Transactions.IsolationLevel"/> to <see cref="IsolationLevel"/>.
  8. /// </summary>
  9. public static IsolationLevel ToSystemDataIsolationLevel(this System.Transactions.IsolationLevel isolationLevel)
  10. {
  11. switch (isolationLevel)
  12. {
  13. case System.Transactions.IsolationLevel.Chaos:
  14. return IsolationLevel.Chaos;
  15. case System.Transactions.IsolationLevel.ReadCommitted:
  16. return IsolationLevel.ReadCommitted;
  17. case System.Transactions.IsolationLevel.ReadUncommitted:
  18. return IsolationLevel.ReadUncommitted;
  19. case System.Transactions.IsolationLevel.RepeatableRead:
  20. return IsolationLevel.RepeatableRead;
  21. case System.Transactions.IsolationLevel.Serializable:
  22. return IsolationLevel.Serializable;
  23. case System.Transactions.IsolationLevel.Snapshot:
  24. return IsolationLevel.Snapshot;
  25. case System.Transactions.IsolationLevel.Unspecified:
  26. return IsolationLevel.Unspecified;
  27. default:
  28. throw new AbpException("Unknown isolation level: " + isolationLevel);
  29. }
  30. }
  31. }
  32. }