**** Merged from MCS ****
[mono-project.git] / mcs / class / System.Data / System.Data.Common / DataAdapter.cs
blob511fa327b1512d1b6009e341c6abba10959e44a7
1 //
2 // System.Data.Common.DataAdapter
3 //
4 // Author:
5 // Rodrigo Moya (rodrigo@ximian.com)
6 // Tim Coleman (tim@timcoleman.com)
7 //
8 // (C) Ximian, Inc
9 // Copyright (C) Tim Coleman, 2002-2003
13 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
15 // Permission is hereby granted, free of charge, to any person obtaining
16 // a copy of this software and associated documentation files (the
17 // "Software"), to deal in the Software without restriction, including
18 // without limitation the rights to use, copy, modify, merge, publish,
19 // distribute, sublicense, and/or sell copies of the Software, and to
20 // permit persons to whom the Software is furnished to do so, subject to
21 // the following conditions:
22 //
23 // The above copyright notice and this permission notice shall be
24 // included in all copies or substantial portions of the Software.
25 //
26 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
30 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
31 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
32 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35 using System.ComponentModel;
36 using System.Data;
38 namespace System.Data.Common
40 /// <summary>
41 /// Represents a set of data commands and a database connection that are used to fill the DataSet and update the data source.
42 /// </summary>
43 public abstract class DataAdapter : Component, IDataAdapter
45 #region Fields
47 private bool acceptChangesDuringFill;
48 private bool continueUpdateOnError;
49 private MissingMappingAction missingMappingAction;
50 private MissingSchemaAction missingSchemaAction;
51 private DataTableMappingCollection tableMappings;
53 #if NET_2_0
54 private bool acceptChangesDuringUpdate;
55 private LoadOption fillLoadOption;
56 private bool returnProviderSpecificTypes;
57 #endif
59 #endregion
61 #region Constructors
63 protected DataAdapter ()
65 acceptChangesDuringFill = true;
66 continueUpdateOnError = false;
67 missingMappingAction = MissingMappingAction.Passthrough;
68 missingSchemaAction = MissingSchemaAction.Add;
69 tableMappings = new DataTableMappingCollection ();
72 protected DataAdapter (DataAdapter adapter)
74 AcceptChangesDuringFill = adapter.AcceptChangesDuringFill;
75 ContinueUpdateOnError = adapter.ContinueUpdateOnError;
76 MissingMappingAction = adapter.MissingMappingAction;
77 MissingSchemaAction = adapter.MissingSchemaAction;
78 if (adapter.tableMappings == null || adapter.TableMappings.Count <= 0) {
79 return;
81 foreach (ICloneable cloneable in adapter.TableMappings) {
82 TableMappings.Add (cloneable.Clone ());
86 #endregion
88 #region Properties
90 [DataCategory ("Fill")]
91 [DataSysDescription ("Whether or not Fill will call DataRow.AcceptChanges.")]
92 [DefaultValue (true)]
93 public bool AcceptChangesDuringFill {
94 get { return acceptChangesDuringFill; }
95 set { acceptChangesDuringFill = value; }
98 #if NET_2_0
99 public bool AcceptChangesDuringUpdate {
100 get { return acceptChangesDuringUpdate; }
101 set { acceptChangesDuringUpdate = value; }
103 #endif
105 [DataCategory ("Update")]
106 [DataSysDescription ("Whether or not to continue to the next DataRow when the Update events, RowUpdating and RowUpdated, Status is UpdateStatus.ErrorsOccurred.")]
107 [DefaultValue (false)]
108 public bool ContinueUpdateOnError {
109 get { return continueUpdateOnError; }
110 set { continueUpdateOnError = value; }
113 #if NET_2_0
114 public LoadOption FillLoadOption {
115 get { return fillLoadOption; }
116 set { fillLoadOption = value; }
118 #endif
120 ITableMappingCollection IDataAdapter.TableMappings {
121 get { return TableMappings; }
124 [DataCategory ("Mapping")]
125 [DataSysDescription ("The action taken when a table or column in the TableMappings is missing.")]
126 [DefaultValue (MissingMappingAction.Passthrough)]
127 public MissingMappingAction MissingMappingAction {
128 get { return missingMappingAction; }
129 set { missingMappingAction = value; }
132 [DataCategory ("Mapping")]
133 [DataSysDescription ("The action taken when a table or column in the DataSet is missing.")]
134 [DefaultValue (MissingSchemaAction.Add)]
135 public MissingSchemaAction MissingSchemaAction {
136 get { return missingSchemaAction; }
137 set { missingSchemaAction = value; }
140 #if NET_2_0
141 public virtual bool ReturnProviderSpecificTypes {
142 get { return returnProviderSpecificTypes; }
143 set { returnProviderSpecificTypes = value; }
145 #endif
147 [DataCategory ("Mapping")]
148 [DataSysDescription ("How to map source table to DataSet table.")]
149 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
150 public DataTableMappingCollection TableMappings {
151 get { return tableMappings; }
154 #endregion
156 #region Events
158 #if NET_2_0
159 public event FillErrorEventHandler FillError;
160 #endif
162 #endregion
164 #region Methods
166 #if NET_1_1
167 [Obsolete ("Use the protected constructor instead", false)]
168 #endif
169 [MonoTODO]
170 protected virtual DataAdapter CloneInternals ()
172 throw new NotImplementedException ();
175 protected virtual DataTableMappingCollection CreateTableMappings ()
177 tableMappings = new DataTableMappingCollection ();
178 return tableMappings;
181 [MonoTODO]
182 protected override void Dispose (bool disposing)
184 throw new NotImplementedException ();
187 public abstract int Fill (DataSet dataSet);
189 #if NET_2_0
190 [MonoTODO]
191 protected virtual int Fill (DataTable dataTable, IDataReader dataReader)
193 throw new NotImplementedException ();
196 [MonoTODO]
197 protected virtual int Fill (DataTable[] dataTables, IDataReader dataReader, int startRecord, int maxRecords)
199 throw new NotImplementedException ();
202 [MonoTODO]
203 protected virtual int Fill (DataSet dataSet, string srcTable, IDataReader dataReader, int startRecord, int maxRecords)
205 throw new NotImplementedException ();
208 [MonoTODO]
209 public static int FillDataSet (IDataReader dataReader, LoadOption fillLoadOption, DataSet dataSet)
211 throw new NotImplementedException ();
214 [MonoTODO]
215 public static int FillDataTable (IDataReader dataReader, LoadOption fillLoadOption, DataTable[] dataTables)
217 throw new NotImplementedException ();
219 #endif
221 public abstract DataTable[] FillSchema (DataSet dataSet, SchemaType schemaType);
223 #if NET_2_0
224 [MonoTODO]
225 protected virtual DataTable FillSchema (DataTable dataTable, SchemaType schemaType, IDataReader dataReader)
227 throw new NotImplementedException ();
230 [MonoTODO]
231 protected virtual DataTable[] FillSchema (DataSet dataSet, SchemaType schemaType, string srcTable, IDataReader dataReader)
233 throw new NotImplementedException ();
235 #endif
237 public abstract IDataParameter[] GetFillParameters ();
239 #if NET_2_0
240 [MonoTODO]
241 protected bool HasTableMappings ()
243 throw new NotImplementedException ();
246 [MonoTODO]
247 protected virtual void OnFillError (FillErrorEventArgs value)
249 throw new NotImplementedException ();
252 [MonoTODO]
253 public void ResetFillLoadOption ()
255 throw new NotImplementedException ();
258 [MonoTODO]
259 public virtual bool ShouldSerializeAcceptChangesDuringFill ()
261 throw new NotImplementedException ();
264 [MonoTODO]
265 public virtual bool ShouldSerializeFillLoadOption ()
267 throw new NotImplementedException ();
269 #endif
271 [MonoTODO]
272 protected virtual bool ShouldSerializeTableMappings ()
274 throw new NotImplementedException ();
277 public abstract int Update (DataSet dataSet);
279 #endregion