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