Exceptions.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data.Linq.Provider;
  4. using System.Linq;
  5. using System.Diagnostics.CodeAnalysis;
  6. namespace System.Data.Linq {
  7. /// <summary>
  8. /// DLinq-specific custom exception factory.
  9. /// </summary>
  10. [SuppressMessage("Microsoft.Usage", "CA2237:MarkISerializableTypesWithSerializable", Justification = "Unknown reason.")]
  11. [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", Justification = "Unknown reason.")]
  12. public class ChangeConflictException : Exception {
  13. public ChangeConflictException() { }
  14. public ChangeConflictException(string message) : base(message) { }
  15. public ChangeConflictException(string message, Exception innerException) : base(message, innerException) { }
  16. }
  17. /// <summary>
  18. /// An attempt was made to add an object to the identity cache with a key that is already in use
  19. /// </summary>
  20. [SuppressMessage("Microsoft.Usage", "CA2237:MarkISerializableTypesWithSerializable", Justification = "Unknown reason.")]
  21. [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", Justification = "Unknown reason.")]
  22. public class DuplicateKeyException : InvalidOperationException {
  23. private object duplicate;
  24. public DuplicateKeyException(object duplicate) {
  25. this.duplicate = duplicate;
  26. }
  27. public DuplicateKeyException(object duplicate, string message)
  28. : base(message) {
  29. this.duplicate = duplicate;
  30. }
  31. public DuplicateKeyException(object duplicate, string message, Exception innerException)
  32. : base(message, innerException) {
  33. this.duplicate = duplicate;
  34. }
  35. /// <summary>
  36. /// The object whose duplicate key caused the exception.
  37. /// </summary>
  38. public object Object {
  39. get {
  40. return duplicate;
  41. }
  42. }
  43. }
  44. /// <summary>
  45. /// An attempt was made to change an FK but the Entity is Loaded
  46. /// </summary>
  47. [SuppressMessage("Microsoft.Usage", "CA2237:MarkISerializableTypesWithSerializable", Justification = "Unknown reason.")]
  48. [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", Justification = "Unknown reason.")]
  49. public class ForeignKeyReferenceAlreadyHasValueException : InvalidOperationException {
  50. public ForeignKeyReferenceAlreadyHasValueException() { }
  51. public ForeignKeyReferenceAlreadyHasValueException(string message) : base(message) { }
  52. public ForeignKeyReferenceAlreadyHasValueException(string message, Exception innerException) : base(message, innerException) { }
  53. }
  54. }