DataAdapter.cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. //
  2. // System.Data.Common.DataAdapter
  3. //
  4. // Author:
  5. // Rodrigo Moya ([email protected])
  6. // Tim Coleman ([email protected])
  7. //
  8. // (C) Ximian, Inc
  9. // Copyright (C) Tim Coleman, 2002-2003
  10. //
  11. using System.ComponentModel;
  12. using System.Data;
  13. namespace System.Data.Common
  14. {
  15. /// <summary>
  16. /// Represents a set of data commands and a database connection that are used to fill the DataSet and update the data source.
  17. /// </summary>
  18. public abstract class DataAdapter : Component, IDataAdapter
  19. {
  20. #region Fields
  21. private bool acceptChangesDuringFill;
  22. private bool continueUpdateOnError;
  23. private MissingMappingAction missingMappingAction;
  24. private MissingSchemaAction missingSchemaAction;
  25. private DataTableMappingCollection tableMappings;
  26. #if NET_1_2
  27. private bool acceptChangesDuringUpdate;
  28. private LoadOption fillLoadOption;
  29. private bool returnProviderSpecificTypes;
  30. #endif
  31. #endregion
  32. #region Constructors
  33. protected DataAdapter ()
  34. {
  35. acceptChangesDuringFill = true;
  36. continueUpdateOnError = false;
  37. missingMappingAction = MissingMappingAction.Passthrough;
  38. missingSchemaAction = MissingSchemaAction.Add;
  39. tableMappings = new DataTableMappingCollection ();
  40. }
  41. #endregion
  42. #region Properties
  43. [DataCategory ("Fill")]
  44. [DataSysDescription ("Whether or not Fill will call DataRow.AcceptChanges.")]
  45. [DefaultValue (true)]
  46. public bool AcceptChangesDuringFill {
  47. get { return acceptChangesDuringFill; }
  48. set { acceptChangesDuringFill = value; }
  49. }
  50. #if NET_1_2
  51. public bool AcceptChangesDuringUpdate {
  52. get { return acceptChangesDuringUpdate; }
  53. set { acceptChangesDuringUpdate = value; }
  54. }
  55. #endif
  56. [DataCategory ("Update")]
  57. [DataSysDescription ("Whether or not to continue to the next DataRow when the Update events, RowUpdating and RowUpdated, Status is UpdateStatus.ErrorsOccurred.")]
  58. [DefaultValue (false)]
  59. public bool ContinueUpdateOnError {
  60. get { return continueUpdateOnError; }
  61. set { continueUpdateOnError = value; }
  62. }
  63. #if NET_1_2
  64. public LoadOption FillLoadOption {
  65. get { return fillLoadOption; }
  66. set { fillLoadOption = value; }
  67. }
  68. #endif
  69. ITableMappingCollection IDataAdapter.TableMappings {
  70. get { return TableMappings; }
  71. }
  72. [DataCategory ("Mapping")]
  73. [DataSysDescription ("The action taken when a table or column in the TableMappings is missing.")]
  74. [DefaultValue (MissingMappingAction.Passthrough)]
  75. public MissingMappingAction MissingMappingAction {
  76. get { return missingMappingAction; }
  77. set { missingMappingAction = value; }
  78. }
  79. [DataCategory ("Mapping")]
  80. [DataSysDescription ("The action taken when a table or column in the DataSet is missing.")]
  81. [DefaultValue (MissingSchemaAction.Add)]
  82. public MissingSchemaAction MissingSchemaAction {
  83. get { return missingSchemaAction; }
  84. set { missingSchemaAction = value; }
  85. }
  86. #if NET_1_2
  87. public virtual bool ReturnProviderSpecificTypes {
  88. get { return returnProviderSpecificTypes; }
  89. set { returnProviderSpecificTypes = value; }
  90. }
  91. #endif
  92. [DataCategory ("Mapping")]
  93. [DataSysDescription ("How to map source table to DataSet table.")]
  94. [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
  95. public DataTableMappingCollection TableMappings {
  96. get { return tableMappings; }
  97. }
  98. #endregion
  99. #region Events
  100. #if NET_1_2
  101. public event FillErrorEventHandler FillError;
  102. #endif
  103. #endregion
  104. #region Methods
  105. #if NET_1_1
  106. [Obsolete ("Use the protected constructor instead", false)]
  107. #endif
  108. [MonoTODO]
  109. protected virtual DataAdapter CloneInternals ()
  110. {
  111. throw new NotImplementedException ();
  112. }
  113. protected virtual DataTableMappingCollection CreateTableMappings ()
  114. {
  115. tableMappings = new DataTableMappingCollection ();
  116. return tableMappings;
  117. }
  118. [MonoTODO]
  119. protected override void Dispose (bool disposing)
  120. {
  121. throw new NotImplementedException ();
  122. }
  123. public abstract int Fill (DataSet dataSet);
  124. #if NET_1_2
  125. [MonoTODO]
  126. protected virtual int Fill (DataTable dataTable, IDataReader dataReader)
  127. {
  128. throw new NotImplementedException ();
  129. }
  130. [MonoTODO]
  131. protected virtual int Fill (DataTable[] dataTables, IDataReader dataReader, int startRecord, int maxRecords)
  132. {
  133. throw new NotImplementedException ();
  134. }
  135. [MonoTODO]
  136. protected virtual int Fill (DataSet dataSet, string srcTable, IDataReader dataReader, int startRecord, int maxRecords)
  137. {
  138. throw new NotImplementedException ();
  139. }
  140. [MonoTODO]
  141. public static int FillDataSet (IDataReader dataReader, LoadOption fillLoadOption, DataSet dataSet)
  142. {
  143. throw new NotImplementedException ();
  144. }
  145. [MonoTODO]
  146. public static int FillDataTable (IDataReader dataReader, LoadOption fillLoadOption, DataTable[] dataTables)
  147. {
  148. throw new NotImplementedException ();
  149. }
  150. #endif
  151. public abstract DataTable[] FillSchema (DataSet dataSet, SchemaType schemaType);
  152. #if NET_1_2
  153. [MonoTODO]
  154. protected virtual DataTable FillSchema (DataTable dataTable, SchemaType schemaType, IDataReader dataReader)
  155. {
  156. throw new NotImplementedException ();
  157. }
  158. [MonoTODO]
  159. protected virtual DataTable[] FillSchema (DataSet dataSet, SchemaType schemaType, string srcTable, IDataReader dataReader)
  160. {
  161. throw new NotImplementedException ();
  162. }
  163. #endif
  164. public abstract IDataParameter[] GetFillParameters ();
  165. #if NET_1_2
  166. [MonoTODO]
  167. protected bool HasTableMappings ()
  168. {
  169. throw new NotImplementedException ();
  170. }
  171. [MonoTODO]
  172. protected virtual void OnFillError (FillErrorEventArgs value)
  173. {
  174. throw new NotImplementedException ();
  175. }
  176. [MonoTODO]
  177. public void ResetFillLoadOption ()
  178. {
  179. throw new NotImplementedException ();
  180. }
  181. [MonoTODO]
  182. public virtual bool ShouldSerializeAcceptChangesDuringFill ()
  183. {
  184. throw new NotImplementedException ();
  185. }
  186. [MonoTODO]
  187. public virtual bool ShouldSerializeFillLoadOption ()
  188. {
  189. throw new NotImplementedException ();
  190. }
  191. #endif
  192. [MonoTODO]
  193. protected virtual bool ShouldSerializeTableMappings ()
  194. {
  195. throw new NotImplementedException ();
  196. }
  197. public abstract int Update (DataSet dataSet);
  198. #endregion
  199. }
  200. }