2 // System.Data.Common.DataAdapter
5 // Rodrigo Moya (rodrigo@ximian.com)
6 // Tim Coleman (tim@timcoleman.com)
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:
23 // The above copyright notice and this permission notice shall be
24 // included in all copies or substantial portions of the Software.
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
;
38 namespace System
.Data
.Common
41 /// Represents a set of data commands and a database connection that are used to fill the DataSet and update the data source.
43 public abstract class DataAdapter
: Component
, IDataAdapter
47 private bool acceptChangesDuringFill
;
48 private bool continueUpdateOnError
;
49 private MissingMappingAction missingMappingAction
;
50 private MissingSchemaAction missingSchemaAction
;
51 private DataTableMappingCollection tableMappings
;
54 private bool acceptChangesDuringUpdate
;
55 private LoadOption fillLoadOption
;
56 private bool returnProviderSpecificTypes
;
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) {
81 foreach (ICloneable cloneable
in adapter
.TableMappings
) {
82 TableMappings
.Add (cloneable
.Clone ());
90 [DataCategory ("Fill")]
91 [DataSysDescription ("Whether or not Fill will call DataRow.AcceptChanges.")]
93 public bool AcceptChangesDuringFill
{
94 get { return acceptChangesDuringFill; }
95 set { acceptChangesDuringFill = value; }
99 public bool AcceptChangesDuringUpdate
{
100 get { return acceptChangesDuringUpdate; }
101 set { acceptChangesDuringUpdate = value; }
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; }
114 public LoadOption FillLoadOption
{
115 get { return fillLoadOption; }
116 set { fillLoadOption = value; }
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; }
141 public virtual bool ReturnProviderSpecificTypes
{
142 get { return returnProviderSpecificTypes; }
143 set { returnProviderSpecificTypes = value; }
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; }
159 public event FillErrorEventHandler FillError
;
167 [Obsolete ("Use the protected constructor instead", false)]
170 protected virtual DataAdapter
CloneInternals ()
172 throw new NotImplementedException ();
175 protected virtual DataTableMappingCollection
CreateTableMappings ()
177 tableMappings
= new DataTableMappingCollection ();
178 return tableMappings
;
182 protected override void Dispose (bool disposing
)
184 throw new NotImplementedException ();
187 public abstract int Fill (DataSet dataSet
);
191 protected virtual int Fill (DataTable dataTable
, IDataReader dataReader
)
193 throw new NotImplementedException ();
197 protected virtual int Fill (DataTable
[] dataTables
, IDataReader dataReader
, int startRecord
, int maxRecords
)
199 throw new NotImplementedException ();
203 protected virtual int Fill (DataSet dataSet
, string srcTable
, IDataReader dataReader
, int startRecord
, int maxRecords
)
205 throw new NotImplementedException ();
209 public static int FillDataSet (IDataReader dataReader
, LoadOption fillLoadOption
, DataSet dataSet
)
211 throw new NotImplementedException ();
215 public static int FillDataTable (IDataReader dataReader
, LoadOption fillLoadOption
, DataTable
[] dataTables
)
217 throw new NotImplementedException ();
221 public abstract DataTable
[] FillSchema (DataSet dataSet
, SchemaType schemaType
);
225 protected virtual DataTable
FillSchema (DataTable dataTable
, SchemaType schemaType
, IDataReader dataReader
)
227 throw new NotImplementedException ();
231 protected virtual DataTable
[] FillSchema (DataSet dataSet
, SchemaType schemaType
, string srcTable
, IDataReader dataReader
)
233 throw new NotImplementedException ();
237 public abstract IDataParameter
[] GetFillParameters ();
241 protected bool HasTableMappings ()
243 throw new NotImplementedException ();
247 protected virtual void OnFillError (FillErrorEventArgs
value)
249 throw new NotImplementedException ();
253 public void ResetFillLoadOption ()
255 throw new NotImplementedException ();
259 public virtual bool ShouldSerializeAcceptChangesDuringFill ()
261 throw new NotImplementedException ();
265 public virtual bool ShouldSerializeFillLoadOption ()
267 throw new NotImplementedException ();
272 protected virtual bool ShouldSerializeTableMappings ()
274 throw new NotImplementedException ();
277 public abstract int Update (DataSet dataSet
);