imported everything from my branch (which is slightly harmless).
[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 using System.Drawing.Design;
29
30 namespace System.Data.OracleClient {
31         [DefaultEvent ("RowUpdated")]
32         [Designer ("Microsoft.VSDesigner.Data.VS.OracleDataAdapterDesigner, " + Consts.AssemblyMicrosoft_VSDesigner)]
33         [ToolboxItem ("Microsoft.VSDesigner.Data.VS.OracleDataAdapterToolboxItem, " + Consts.AssemblyMicrosoft_VSDesigner)]
34         public sealed class OracleDataAdapter : DbDataAdapter, IDbDataAdapter 
35         {
36                 #region Fields
37
38                 bool disposed = false;  
39                 OracleCommand deleteCommand;
40                 OracleCommand insertCommand;
41                 OracleCommand selectCommand;
42                 OracleCommand updateCommand;
43
44                 #endregion
45
46                 #region Constructors
47                 
48                 public OracleDataAdapter ()     
49                         : this (new OracleCommand ())
50                 {
51                 }
52
53                 public OracleDataAdapter (OracleCommand selectCommand) 
54                 {
55                         DeleteCommand = null;
56                         InsertCommand = null;
57                         SelectCommand = selectCommand;
58                         UpdateCommand = null;
59                 }
60
61                 public OracleDataAdapter (string selectCommandText, OracleConnection selectConnection) 
62                         : this (new OracleCommand (selectCommandText, selectConnection))
63                 { 
64                 }
65
66                 public OracleDataAdapter (string selectCommandText, string selectConnectionString)
67                         : this (selectCommandText, new OracleConnection (selectConnectionString))
68                 {
69                 }
70
71                 #endregion
72
73                 #region Properties
74
75                 [DefaultValue (null)]
76                 [Editor ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, " + Consts.AssemblyMicrosoft_VSDesigner, typeof(UITypeEditor))]
77                 public OracleCommand DeleteCommand {
78                         get { return deleteCommand; }
79                         set { deleteCommand = value; }
80                 }
81
82                 [DefaultValue (null)]
83                 [Editor ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, " + Consts.AssemblyMicrosoft_VSDesigner, typeof(UITypeEditor))]
84                 public OracleCommand InsertCommand {
85                         get { return insertCommand; }
86                         set { insertCommand = value; }
87                 }
88
89                 [DefaultValue (null)]
90                 [Editor ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, " + Consts.AssemblyMicrosoft_VSDesigner, typeof(UITypeEditor))]
91                 public OracleCommand SelectCommand {
92                         get { return selectCommand; }
93                         set { selectCommand = value; }
94                 }
95
96                 [DefaultValue (null)]
97                 [Editor ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, " + Consts.AssemblyMicrosoft_VSDesigner, typeof(UITypeEditor))]
98                 public OracleCommand UpdateCommand {
99                         get { return updateCommand; }
100                         set { updateCommand = value; }
101                 }
102
103                 IDbCommand IDbDataAdapter.DeleteCommand {
104                         get { return DeleteCommand; }
105                         set { 
106                                 if (!(value is OracleCommand)) 
107                                         throw new ArgumentException ();
108                                 DeleteCommand = (OracleCommand) value;
109                         }
110                 }
111
112                 IDbCommand IDbDataAdapter.InsertCommand {
113                         get { return InsertCommand; }
114                         set { 
115                                 if (!(value is OracleCommand)) 
116                                         throw new ArgumentException ();
117                                 InsertCommand = (OracleCommand) value;
118                         }
119                 }
120
121                 IDbCommand IDbDataAdapter.SelectCommand {
122                         get { return SelectCommand; }
123                         set { 
124                                 if (!(value is OracleCommand)) 
125                                         throw new ArgumentException ();
126                                 SelectCommand = (OracleCommand) value;
127                         }
128                 }
129
130                 IDbCommand IDbDataAdapter.UpdateCommand {
131                         get { return UpdateCommand; }
132                         set { 
133                                 if (!(value is OracleCommand)) 
134                                         throw new ArgumentException ();
135                                 UpdateCommand = (OracleCommand) value;
136                         }
137                 }
138
139
140                 ITableMappingCollection IDataAdapter.TableMappings {
141                         get { return TableMappings; }
142                 }
143
144                 #endregion // Properties
145
146                 #region Methods
147
148                 protected override RowUpdatedEventArgs CreateRowUpdatedEvent (DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) 
149                 {
150                         return new OracleRowUpdatedEventArgs (dataRow, command, statementType, tableMapping);
151                 }
152
153
154                 protected override RowUpdatingEventArgs CreateRowUpdatingEvent (DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) 
155                 {
156                         return new OracleRowUpdatingEventArgs (dataRow, command, statementType, tableMapping);
157                 }
158
159                 protected override void OnRowUpdated (RowUpdatedEventArgs value) 
160                 {
161                         if (RowUpdated != null)
162                                 RowUpdated (this, (OracleRowUpdatedEventArgs) value);
163                 }
164
165                 protected override void OnRowUpdating (RowUpdatingEventArgs value) 
166                 {
167                         if (RowUpdating != null)
168                                 RowUpdating (this, (OracleRowUpdatingEventArgs) value);
169                 }
170
171                 #endregion // Methods
172
173                 #region Events and Delegates
174
175                 public event OracleRowUpdatedEventHandler RowUpdated;
176                 public event OracleRowUpdatingEventHandler RowUpdating;
177
178                 #endregion // Events and Delegates
179
180         }
181 }