Applied patch from: David Pickens <dsp@rci.rutgers.edu>
[mono.git] / mcs / class / System.Data.OracleClient / System.Data.OracleClient / OracleDataAdapter.cs
1 //
2 // OracleDataAdapter.cs
3 //
4 // Part of the Mono class libraries at
5 // mcs/class/System.Data.OracleClient/System.Data.OracleClient
6 //
7 // Assembly: System.Data.OracleClient.dll
8 // Namespace: System.Data.OracleClient
9 //
10 // Author: Tim Coleman <tim@timcoleman.com>
11 //
12 // Parts transferred from System.Data.SqlClient/SqlDataAdapter.cs
13 // Authors:
14 //      Rodrigo Moya (rodrigo@ximian.com)
15 //      Daniel Morgan (danmorg@sc.rr.com)
16 //      Tim Coleman (tim@timcoleman.com)
17 //
18 // Copyright (C) Tim Coleman, 2003
19 // (C) Ximian, Inc 2002
20 //
21 // Licensed under the MIT/X11 License.
22 //
23
24 using System;
25 using System.ComponentModel;
26 using System.Data;
27 using System.Data.Common;
28
29 namespace System.Data.OracleClient {
30         public sealed class OracleDataAdapter : DbDataAdapter, IDbDataAdapter 
31         {
32                 #region Fields
33
34                 bool disposed = false;  
35                 OracleCommand deleteCommand;
36                 OracleCommand insertCommand;
37                 OracleCommand selectCommand;
38                 OracleCommand updateCommand;
39
40                 #endregion
41
42                 #region Constructors
43                 
44                 public OracleDataAdapter ()     
45                         : this (new OracleCommand ())
46                 {
47                 }
48
49                 public OracleDataAdapter (OracleCommand selectCommand) 
50                 {
51                         DeleteCommand = null;
52                         InsertCommand = null;
53                         SelectCommand = selectCommand;
54                         UpdateCommand = null;
55                 }
56
57                 public OracleDataAdapter (string selectCommandText, OracleConnection selectConnection) 
58                         : this (new OracleCommand (selectCommandText, selectConnection))
59                 { 
60                 }
61
62                 public OracleDataAdapter (string selectCommandText, string selectConnectionString)
63                         : this (selectCommandText, new OracleConnection (selectConnectionString))
64                 {
65                 }
66
67                 #endregion
68
69                 #region Properties
70
71                 public OracleCommand DeleteCommand {
72                         get { return deleteCommand; }
73                         set { deleteCommand = value; }
74                 }
75
76                 public OracleCommand InsertCommand {
77                         get { return insertCommand; }
78                         set { insertCommand = value; }
79                 }
80
81                 public OracleCommand SelectCommand {
82                         get { return selectCommand; }
83                         set { selectCommand = value; }
84                 }
85
86                 public OracleCommand UpdateCommand {
87                         get { return updateCommand; }
88                         set { updateCommand = value; }
89                 }
90
91                 IDbCommand IDbDataAdapter.DeleteCommand {
92                         get { return DeleteCommand; }
93                         set { 
94                                 if (!(value is OracleCommand)) 
95                                         throw new ArgumentException ();
96                                 DeleteCommand = (OracleCommand) value;
97                         }
98                 }
99
100                 IDbCommand IDbDataAdapter.InsertCommand {
101                         get { return InsertCommand; }
102                         set { 
103                                 if (!(value is OracleCommand)) 
104                                         throw new ArgumentException ();
105                                 InsertCommand = (OracleCommand) value;
106                         }
107                 }
108
109                 IDbCommand IDbDataAdapter.SelectCommand {
110                         get { return SelectCommand; }
111                         set { 
112                                 if (!(value is OracleCommand)) 
113                                         throw new ArgumentException ();
114                                 SelectCommand = (OracleCommand) value;
115                         }
116                 }
117
118                 IDbCommand IDbDataAdapter.UpdateCommand {
119                         get { return UpdateCommand; }
120                         set { 
121                                 if (!(value is OracleCommand)) 
122                                         throw new ArgumentException ();
123                                 UpdateCommand = (OracleCommand) value;
124                         }
125                 }
126
127
128                 ITableMappingCollection IDataAdapter.TableMappings {
129                         get { return TableMappings; }
130                 }
131
132                 #endregion // Properties
133
134                 #region Methods
135
136                 protected override RowUpdatedEventArgs CreateRowUpdatedEvent (DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) 
137                 {
138                         return new OracleRowUpdatedEventArgs (dataRow, command, statementType, tableMapping);
139                 }
140
141
142                 protected override RowUpdatingEventArgs CreateRowUpdatingEvent (DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) 
143                 {
144                         return new OracleRowUpdatingEventArgs (dataRow, command, statementType, tableMapping);
145                 }
146
147                 protected override void Dispose (bool disposing)
148                 {
149                         if (!disposed) {
150                                 if (disposing) {
151                                         // Release managed resources
152                                 }
153                                 // Release unmanaged resources
154                                 disposed = true;
155                         }
156                 }
157
158                 protected override void OnRowUpdated (RowUpdatedEventArgs value) 
159                 {
160                         if (RowUpdated != null)
161                                 RowUpdated (this, (OracleRowUpdatedEventArgs) value);
162                 }
163
164                 protected override void OnRowUpdating (RowUpdatingEventArgs value) 
165                 {
166                         if (RowUpdating != null)
167                                 RowUpdating (this, (OracleRowUpdatingEventArgs) value);
168                 }
169
170                 #endregion // Methods
171
172                 #region Events and Delegates
173
174                 public event OracleRowUpdatedEventHandler RowUpdated;
175                 public event OracleRowUpdatingEventHandler RowUpdating;
176
177                 #endregion // Events and Delegates
178
179         }
180 }