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