forked from ThatRendle/Simple.Data
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdoAdapterException.cs
More file actions
77 lines (66 loc) · 2.77 KB
/
AdoAdapterException.cs
File metadata and controls
77 lines (66 loc) · 2.77 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Runtime.Serialization;
using Simple.Data.Extensions;
namespace Simple.Data.Ado
{
[Serializable]
public class AdoAdapterException : AdapterException
{
public AdoAdapterException() : base(typeof(AdoAdapter))
{}
public AdoAdapterException(string message)
: base(message, typeof(AdoAdapter))
{}
public AdoAdapterException(string message, Exception inner)
: base(message, inner, typeof(AdoAdapter))
{}
public AdoAdapterException(string message, IDbCommand command)
: base(message, typeof(AdoAdapter))
{
CommandText = command.CommandText;
Parameters = command.Parameters.Cast<IDbDataParameter>()
.ToDictionary(p => p.ParameterName, p => p.Value);
}
public AdoAdapterException(string message, IDbCommand command, Exception inner)
: base(message, inner, typeof(AdoAdapter))
{
CommandText = command.CommandText;
Parameters = command.Parameters.Cast<IDbDataParameter>()
.ToDictionary(p => p.ParameterName, p => p.Value);
}
public AdoAdapterException(string commandText, IEnumerable<KeyValuePair<string, object>> parameters)
: base(typeof(AdoAdapter)) // never used outside tests?
{
CommandText = commandText;
Parameters = parameters.ToDictionary();
}
public AdoAdapterException(string message, string commandText, IEnumerable<KeyValuePair<string, object>> parameters)
: base(message, typeof(AdoAdapter))
{
CommandText = commandText;
Parameters = parameters.ToDictionary();
}
public AdoAdapterException(string message, string commandText, IEnumerable<KeyValuePair<string, object>> parameters, Exception inner)
: base(message, inner, typeof(AdoAdapter))
{
CommandText = commandText;
Parameters = parameters.ToDictionary();
}
protected AdoAdapterException(SerializationInfo info, StreamingContext context)
: base(info, context)
{}
public IDictionary<string, object> Parameters
{
get { return Data.Contains("Parameters") ? ((KeyValuePair<string, object>[])Data["Parameters"]).ToDictionary() : null; }
private set { Data["Parameters"] = value.ToArray(); }
}
public string CommandText
{
get { return Data.Contains("CommandText") ? Data["CommandText"].ToString() : null; }
private set { Data["CommandText"] = value; }
}
}
}