| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282 |
- //
- // System.Data.Common.DataAdapter
- //
- // Author:
- // Rodrigo Moya ([email protected])
- // Tim Coleman ([email protected])
- //
- // (C) Ximian, Inc
- // Copyright (C) Tim Coleman, 2002-2003
- //
- //
- // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
- //
- // Permission is hereby granted, free of charge, to any person obtaining
- // a copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to
- // permit persons to whom the Software is furnished to do so, subject to
- // the following conditions:
- //
- // The above copyright notice and this permission notice shall be
- // included in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- //
- using System.ComponentModel;
- using System.Data;
- namespace System.Data.Common
- {
- /// <summary>
- /// Represents a set of data commands and a database connection that are used to fill the DataSet and update the data source.
- /// </summary>
- public abstract class DataAdapter : Component, IDataAdapter
- {
- #region Fields
- private bool acceptChangesDuringFill;
- private bool continueUpdateOnError;
- private MissingMappingAction missingMappingAction;
- private MissingSchemaAction missingSchemaAction;
- private DataTableMappingCollection tableMappings;
- #if NET_2_0
- private bool acceptChangesDuringUpdate;
- private LoadOption fillLoadOption;
- private bool returnProviderSpecificTypes;
- #endif
- #endregion
- #region Constructors
- protected DataAdapter ()
- {
- acceptChangesDuringFill = true;
- continueUpdateOnError = false;
- missingMappingAction = MissingMappingAction.Passthrough;
- missingSchemaAction = MissingSchemaAction.Add;
- tableMappings = new DataTableMappingCollection ();
- }
- protected DataAdapter (DataAdapter adapter)
- {
- AcceptChangesDuringFill = adapter.AcceptChangesDuringFill;
- ContinueUpdateOnError = adapter.ContinueUpdateOnError;
- MissingMappingAction = adapter.MissingMappingAction;
- MissingSchemaAction = adapter.MissingSchemaAction;
- if (adapter.tableMappings == null || adapter.TableMappings.Count <= 0) {
- return;
- }
- foreach (ICloneable cloneable in adapter.TableMappings) {
- TableMappings.Add (cloneable.Clone ());
- }
- }
- #endregion
- #region Properties
- [DataCategory ("Fill")]
- [DataSysDescription ("Whether or not Fill will call DataRow.AcceptChanges.")]
- [DefaultValue (true)]
- public bool AcceptChangesDuringFill {
- get { return acceptChangesDuringFill; }
- set { acceptChangesDuringFill = value; }
- }
- #if NET_2_0
- public bool AcceptChangesDuringUpdate {
- get { return acceptChangesDuringUpdate; }
- set { acceptChangesDuringUpdate = value; }
- }
- #endif
- [DataCategory ("Update")]
- [DataSysDescription ("Whether or not to continue to the next DataRow when the Update events, RowUpdating and RowUpdated, Status is UpdateStatus.ErrorsOccurred.")]
- [DefaultValue (false)]
- public bool ContinueUpdateOnError {
- get { return continueUpdateOnError; }
- set { continueUpdateOnError = value; }
- }
- #if NET_2_0
- public LoadOption FillLoadOption {
- get { return fillLoadOption; }
- set { fillLoadOption = value; }
- }
- #endif
- ITableMappingCollection IDataAdapter.TableMappings {
- get { return TableMappings; }
- }
- [DataCategory ("Mapping")]
- [DataSysDescription ("The action taken when a table or column in the TableMappings is missing.")]
- [DefaultValue (MissingMappingAction.Passthrough)]
- public MissingMappingAction MissingMappingAction {
- get { return missingMappingAction; }
- set { missingMappingAction = value; }
- }
- [DataCategory ("Mapping")]
- [DataSysDescription ("The action taken when a table or column in the DataSet is missing.")]
- [DefaultValue (MissingSchemaAction.Add)]
- public MissingSchemaAction MissingSchemaAction {
- get { return missingSchemaAction; }
- set { missingSchemaAction = value; }
- }
- #if NET_2_0
- public virtual bool ReturnProviderSpecificTypes {
- get { return returnProviderSpecificTypes; }
- set { returnProviderSpecificTypes = value; }
- }
- #endif
- [DataCategory ("Mapping")]
- [DataSysDescription ("How to map source table to DataSet table.")]
- [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
- public DataTableMappingCollection TableMappings {
- get { return tableMappings; }
- }
- #endregion
- #region Events
- #if NET_2_0
- public event FillErrorEventHandler FillError;
- #endif
- #endregion
- #region Methods
- #if NET_1_1
- [Obsolete ("Use the protected constructor instead", false)]
- #endif
- [MonoTODO]
- protected virtual DataAdapter CloneInternals ()
- {
- throw new NotImplementedException ();
- }
- protected virtual DataTableMappingCollection CreateTableMappings ()
- {
- tableMappings = new DataTableMappingCollection ();
- return tableMappings;
- }
- [MonoTODO]
- protected override void Dispose (bool disposing)
- {
- throw new NotImplementedException ();
- }
- public abstract int Fill (DataSet dataSet);
- #if NET_2_0
- [MonoTODO]
- protected virtual int Fill (DataTable dataTable, IDataReader dataReader)
- {
- throw new NotImplementedException ();
- }
- [MonoTODO]
- protected virtual int Fill (DataTable[] dataTables, IDataReader dataReader, int startRecord, int maxRecords)
- {
- throw new NotImplementedException ();
- }
- [MonoTODO]
- protected virtual int Fill (DataSet dataSet, string srcTable, IDataReader dataReader, int startRecord, int maxRecords)
- {
- throw new NotImplementedException ();
- }
- [MonoTODO]
- public static int FillDataSet (IDataReader dataReader, LoadOption fillLoadOption, DataSet dataSet)
- {
- throw new NotImplementedException ();
- }
- [MonoTODO]
- public static int FillDataTable (IDataReader dataReader, LoadOption fillLoadOption, DataTable[] dataTables)
- {
- throw new NotImplementedException ();
- }
- #endif
- public abstract DataTable[] FillSchema (DataSet dataSet, SchemaType schemaType);
- #if NET_2_0
- [MonoTODO]
- protected virtual DataTable FillSchema (DataTable dataTable, SchemaType schemaType, IDataReader dataReader)
- {
- throw new NotImplementedException ();
- }
- [MonoTODO]
- protected virtual DataTable[] FillSchema (DataSet dataSet, SchemaType schemaType, string srcTable, IDataReader dataReader)
- {
- throw new NotImplementedException ();
- }
- #endif
- public abstract IDataParameter[] GetFillParameters ();
- #if NET_2_0
- [MonoTODO]
- protected bool HasTableMappings ()
- {
- throw new NotImplementedException ();
- }
- [MonoTODO]
- protected virtual void OnFillError (FillErrorEventArgs value)
- {
- throw new NotImplementedException ();
- }
- [MonoTODO]
- public void ResetFillLoadOption ()
- {
- throw new NotImplementedException ();
- }
- [MonoTODO]
- public virtual bool ShouldSerializeAcceptChangesDuringFill ()
- {
- throw new NotImplementedException ();
- }
- [MonoTODO]
- public virtual bool ShouldSerializeFillLoadOption ()
- {
- throw new NotImplementedException ();
- }
- #endif
- [MonoTODO]
- protected virtual bool ShouldSerializeTableMappings ()
- {
- throw new NotImplementedException ();
- }
- public abstract int Update (DataSet dataSet);
- #endregion
-
- }
- }
|