33using System . Data ;
44using System . Linq ;
55using System . Runtime . Serialization ;
6- using System . Text ;
76using Simple . Data . Extensions ;
87
98namespace Simple . Data . Ado
109{
11- using System . Security ;
12-
1310 [ Serializable ]
1411 public class AdoAdapterException : AdapterException
1512 {
1613 public AdoAdapterException ( ) : base ( typeof ( AdoAdapter ) )
14+ { }
15+
16+ public AdoAdapterException ( string message )
17+ : base ( message , typeof ( AdoAdapter ) )
18+ { }
19+
20+ public AdoAdapterException ( string message , Exception inner )
21+ : base ( message , inner , typeof ( AdoAdapter ) )
22+ { }
23+
24+ public AdoAdapterException ( string message , IDbCommand command )
25+ : base ( message , typeof ( AdoAdapter ) )
1726 {
27+ CommandText = command . CommandText ;
28+ Parameters = command . Parameters . Cast < IDbDataParameter > ( )
29+ . ToDictionary ( p => p . ParameterName , p => p . Value ) ;
1830 }
1931
20- public AdoAdapterException ( string message , IDbCommand command ) : base ( message , typeof ( AdoAdapter ) )
32+ public AdoAdapterException ( string message , IDbCommand command , Exception inner )
33+ : base ( message , inner , typeof ( AdoAdapter ) )
2134 {
2235 CommandText = command . CommandText ;
2336 Parameters = command . Parameters . Cast < IDbDataParameter > ( )
2437 . ToDictionary ( p => p . ParameterName , p => p . Value ) ;
2538 }
2639
27- public AdoAdapterException ( string commandText , IEnumerable < KeyValuePair < string , object > > parameters )
28- : base ( typeof ( AdoAdapter ) )
40+ public AdoAdapterException ( string commandText , IEnumerable < KeyValuePair < string , object > > parameters )
41+ : base ( typeof ( AdoAdapter ) ) // never used outside tests?
2942 {
3043 CommandText = commandText ;
3144 Parameters = parameters . ToDictionary ( ) ;
3245 }
3346
34-
35- public AdoAdapterException ( string message ) : base ( message , typeof ( AdoAdapter ) )
36- {
37- }
38-
39- public AdoAdapterException ( string message , string commandText , IEnumerable < KeyValuePair < string , object > > parameters )
40- : base ( message , typeof ( AdoAdapter ) )
47+ public AdoAdapterException ( string message , string commandText , IEnumerable < KeyValuePair < string , object > > parameters )
48+ : base ( message , typeof ( AdoAdapter ) )
4149 {
4250 CommandText = commandText ;
4351 Parameters = parameters . ToDictionary ( ) ;
4452 }
4553
46- public AdoAdapterException ( string message , Exception inner ) : base ( message , inner , typeof ( AdoAdapter ) )
54+ public AdoAdapterException ( string message , string commandText , IEnumerable < KeyValuePair < string , object > > parameters , Exception inner )
55+ : base ( message , inner , typeof ( AdoAdapter ) )
4756 {
57+ CommandText = commandText ;
58+ Parameters = parameters . ToDictionary ( ) ;
4859 }
4960
5061 protected AdoAdapterException ( SerializationInfo info , StreamingContext context )
5162 : base ( info , context )
52- {
53- //CommandText = info.GetString("CommandText");
54- //try
55- //{
56- // var array = info.GetValue("Parameters", typeof(KeyValuePair<string, object>[]));
57- // if (array != null)
58- // {
59- // Parameters = ((KeyValuePair<string, object>[])array);
60- // }
61- //}
62- //catch (SerializationException)
63- //{
64- //}
65- }
63+ { }
6664
6765 public IDictionary < string , object > Parameters
6866 {
69- get { return Data . Contains ( "Parameters" ) ? ( ( KeyValuePair < string , object > [ ] ) Data [ "Parameters" ] ) . ToDictionary ( ) : null ; }
67+ get { return Data . Contains ( "Parameters" ) ? ( ( KeyValuePair < string , object > [ ] ) Data [ "Parameters" ] ) . ToDictionary ( ) : null ; }
7068 private set { Data [ "Parameters" ] = value . ToArray ( ) ; }
7169 }
7270
7371 public string CommandText
7472 {
75- get { return Data . Contains ( "CommandText" ) ? Data [ "CommandText" ] . ToString ( ) : null ; }
73+ get { return Data . Contains ( "CommandText" ) ? Data [ "CommandText" ] . ToString ( ) : null ; }
7674 private set { Data [ "CommandText" ] = value ; }
7775 }
7876 }
79- }
77+ }
0 commit comments