* OracleTransaction.cs: Corcompare fixes for 2.0 profile. Implemented
[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 new OracleCommand DeleteCommand {
80                         get { return deleteCommand; }
81                         set { deleteCommand = value; }
82                 }
83
84                 [DefaultValue (null)]
85                 [Editor ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, " + Consts.AssemblyMicrosoft_VSDesigner, typeof(UITypeEditor))]
86                 public new OracleCommand InsertCommand {
87                         get { return insertCommand; }
88                         set { insertCommand = value; }
89                 }
90
91                 [DefaultValue (null)]
92                 [Editor ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, " + Consts.AssemblyMicrosoft_VSDesigner, typeof(UITypeEditor))]
93                 public new OracleCommand SelectCommand {
94                         get { return selectCommand; }
95                         set { selectCommand = value; }
96                 }
97
98                 [DefaultValue (null)]
99                 [Editor ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, " + Consts.AssemblyMicrosoft_VSDesigner, typeof(UITypeEditor))]
100                 public new OracleCommand UpdateCommand {
101                         get { return updateCommand; }
102                         set { updateCommand = value; }
103                 }
104
105 #if NET_2_0
106                 public override int UpdateBatchSize {
107                         get { return updateBatchSize; }
108                         set {
109                                 if (value < 0)
110                                         throw new ArgumentOutOfRangeException ("UpdateBatchSize");
111                                 updateBatchSize = value; 
112                         }
113                 }
114 #endif
115
116                 IDbCommand IDbDataAdapter.DeleteCommand {
117                         get { return DeleteCommand; }
118                         set { DeleteCommand = (OracleCommand) value; }
119                 }
120
121                 IDbCommand IDbDataAdapter.InsertCommand {
122                         get { return InsertCommand; }
123                         set { InsertCommand = (OracleCommand) value; }
124                 }
125
126                 IDbCommand IDbDataAdapter.SelectCommand {
127                         get { return SelectCommand; }
128                         set { SelectCommand = (OracleCommand) value; }
129                 }
130
131                 IDbCommand IDbDataAdapter.UpdateCommand {
132                         get { return UpdateCommand; }
133                         set { UpdateCommand = (OracleCommand) value; }
134                 }
135
136                 #endregion // Properties
137
138                 #region Methods
139
140                 protected override RowUpdatedEventArgs CreateRowUpdatedEvent (DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
141                 {
142                         return new OracleRowUpdatedEventArgs (dataRow, command, statementType, tableMapping);
143                 }
144
145
146                 protected override RowUpdatingEventArgs CreateRowUpdatingEvent (DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
147                 {
148                         return new OracleRowUpdatingEventArgs (dataRow, command, statementType, tableMapping);
149                 }
150
151                 protected override void OnRowUpdated (RowUpdatedEventArgs value)
152                 {
153                         if (RowUpdated != null)
154                                 RowUpdated (this, (OracleRowUpdatedEventArgs) value);
155                 }
156
157                 protected override void OnRowUpdating (RowUpdatingEventArgs value)
158                 {
159                         if (RowUpdating != null)
160                                 RowUpdating (this, (OracleRowUpdatingEventArgs) value);
161                 }
162
163                 #endregion // Methods
164
165                 #region Events and Delegates
166
167                 public event OracleRowUpdatedEventHandler RowUpdated;
168                 public event OracleRowUpdatingEventHandler RowUpdating;
169
170                 #endregion // Events and Delegates
171         }
172 }