forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConstraintViolationException.cs
51 lines (46 loc) · 1.41 KB
/
ConstraintViolationException.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.Runtime.Serialization;
using System.Security;
namespace NHibernate.Exceptions
{
/// <summary>
/// Implementation of ADOException indicating that the requested DML operation
/// resulted in a violation of a defined integrity constraint.
/// </summary>
[Serializable]
public class ConstraintViolationException : ADOException
{
public ConstraintViolationException(string message, Exception innerException, string sql, string constraintName)
: base(message, innerException, sql)
{
ConstraintName = constraintName;
}
public ConstraintViolationException(string message, Exception innerException, string constraintName)
: base(message, innerException)
{
ConstraintName = constraintName;
}
public ConstraintViolationException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
foreach (var entry in info)
{
if (entry.Name == "ConstraintName")
{
ConstraintName = entry.Value?.ToString();
}
}
}
[SecurityCritical]
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
info.AddValue("ConstraintName", ConstraintName);
}
/// <summary>
/// Returns the name of the violated constraint, if known.
/// </summary>
/// <returns> The name of the violated constraint, or null if not known. </returns>
public string ConstraintName { get; }
}
}