DataAdapter.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  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. //
  12. // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
  13. //
  14. // Permission is hereby granted, free of charge, to any person obtaining
  15. // a copy of this software and associated documentation files (the
  16. // "Software"), to deal in the Software without restriction, including
  17. // without limitation the rights to use, copy, modify, merge, publish,
  18. // distribute, sublicense, and/or sell copies of the Software, and to
  19. // permit persons to whom the Software is furnished to do so, subject to
  20. // the following conditions:
  21. //
  22. // The above copyright notice and this permission notice shall be
  23. // included in all copies or substantial portions of the Software.
  24. //
  25. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  26. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  27. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  28. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  29. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  30. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  31. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  32. //
  33. using System;
  34. using System.Data;
  35. using System.Collections;
  36. using System.ComponentModel;
  37. namespace System.Data.Common
  38. {
  39. /// <summary>
  40. /// Represents a set of data commands and a database connection that are used to fill the DataSet and update the data source.
  41. /// </summary>
  42. public
  43. #if ONLY_1_1
  44. abstract
  45. #endif
  46. class DataAdapter : Component, IDataAdapter
  47. {
  48. #region Fields
  49. private bool acceptChangesDuringFill;
  50. private bool continueUpdateOnError;
  51. private MissingMappingAction missingMappingAction;
  52. private MissingSchemaAction missingSchemaAction;
  53. private DataTableMappingCollection tableMappings;
  54. private const string DefaultSourceTableName = "Table";
  55. private const string DefaultSourceColumnName = "Column";
  56. #if NET_2_0
  57. private bool acceptChangesDuringUpdate;
  58. private LoadOption fillLoadOption;
  59. private bool returnProviderSpecificTypes;
  60. #endif
  61. #endregion
  62. #region Constructors
  63. protected DataAdapter ()
  64. {
  65. acceptChangesDuringFill = true;
  66. continueUpdateOnError = false;
  67. missingMappingAction = MissingMappingAction.Passthrough;
  68. missingSchemaAction = MissingSchemaAction.Add;
  69. tableMappings = new DataTableMappingCollection ();
  70. #if NET_2_0
  71. acceptChangesDuringUpdate = true;
  72. fillLoadOption = LoadOption.OverwriteChanges;
  73. returnProviderSpecificTypes = false;
  74. #endif
  75. }
  76. protected DataAdapter (DataAdapter adapter)
  77. {
  78. AcceptChangesDuringFill = adapter.AcceptChangesDuringFill;
  79. ContinueUpdateOnError = adapter.ContinueUpdateOnError;
  80. MissingMappingAction = adapter.MissingMappingAction;
  81. MissingSchemaAction = adapter.MissingSchemaAction;
  82. if (adapter.tableMappings != null)
  83. foreach (ICloneable cloneable in adapter.TableMappings)
  84. TableMappings.Add (cloneable.Clone ());
  85. #if NET_2_0
  86. acceptChangesDuringUpdate = adapter.AcceptChangesDuringUpdate;
  87. fillLoadOption = adapter.FillLoadOption;
  88. returnProviderSpecificTypes = adapter.ReturnProviderSpecificTypes;
  89. #endif
  90. }
  91. #endregion
  92. #region Properties
  93. [DataCategory ("Fill")]
  94. #if !NET_2_0
  95. [DataSysDescription ("Whether or not Fill will call DataRow.AcceptChanges.")]
  96. #endif
  97. [DefaultValue (true)]
  98. public bool AcceptChangesDuringFill {
  99. get { return acceptChangesDuringFill; }
  100. set { acceptChangesDuringFill = value; }
  101. }
  102. #if NET_2_0
  103. [DefaultValue (true)]
  104. public bool AcceptChangesDuringUpdate {
  105. get { return acceptChangesDuringUpdate; }
  106. set { acceptChangesDuringUpdate = value; }
  107. }
  108. #endif
  109. [DataCategory ("Update")]
  110. #if !NET_2_0
  111. [DataSysDescription ("Whether or not to continue to the next DataRow when the Update events, RowUpdating and RowUpdated, Status is UpdateStatus.ErrorsOccurred.")]
  112. #endif
  113. [DefaultValue (false)]
  114. public bool ContinueUpdateOnError {
  115. get { return continueUpdateOnError; }
  116. set { continueUpdateOnError = value; }
  117. }
  118. #if NET_2_0
  119. [RefreshProperties (RefreshProperties.All)]
  120. public LoadOption FillLoadOption {
  121. get { return fillLoadOption; }
  122. set {
  123. ExceptionHelper.CheckEnumValue (typeof (LoadOption), value);
  124. fillLoadOption = value;
  125. }
  126. }
  127. #endif
  128. ITableMappingCollection IDataAdapter.TableMappings {
  129. get { return TableMappings; }
  130. }
  131. [DataCategory ("Mapping")]
  132. #if !NET_2_0
  133. [DataSysDescription ("The action taken when a table or column in the TableMappings is missing.")]
  134. #endif
  135. [DefaultValue (MissingMappingAction.Passthrough)]
  136. public MissingMappingAction MissingMappingAction {
  137. get { return missingMappingAction; }
  138. set {
  139. ExceptionHelper.CheckEnumValue (typeof (MissingMappingAction), value);
  140. missingMappingAction = value;
  141. }
  142. }
  143. [DataCategory ("Mapping")]
  144. #if !NET_2_0
  145. [DataSysDescription ("The action taken when a table or column in the DataSet is missing.")]
  146. #endif
  147. [DefaultValue (MissingSchemaAction.Add)]
  148. public MissingSchemaAction MissingSchemaAction {
  149. get { return missingSchemaAction; }
  150. set {
  151. ExceptionHelper.CheckEnumValue (typeof (MissingSchemaAction), value);
  152. missingSchemaAction = value;
  153. }
  154. }
  155. #if NET_2_0
  156. [DefaultValue (false)]
  157. public virtual bool ReturnProviderSpecificTypes {
  158. get { return returnProviderSpecificTypes; }
  159. set { returnProviderSpecificTypes = value; }
  160. }
  161. #endif
  162. [DataCategory ("Mapping")]
  163. #if !NET_2_0
  164. [DataSysDescription ("How to map source table to DataSet table.")]
  165. #endif
  166. [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
  167. public DataTableMappingCollection TableMappings {
  168. get { return tableMappings; }
  169. }
  170. #endregion
  171. #region Events
  172. #if NET_2_0
  173. public event FillErrorEventHandler FillError;
  174. #endif
  175. #endregion
  176. #region Methods
  177. #if !ONLY_1_0
  178. [Obsolete ("Use the protected constructor instead", false)]
  179. #endif
  180. [MonoTODO]
  181. protected virtual DataAdapter CloneInternals ()
  182. {
  183. throw new NotImplementedException ();
  184. }
  185. protected virtual DataTableMappingCollection CreateTableMappings ()
  186. {
  187. return new DataTableMappingCollection ();
  188. }
  189. [MonoTODO]
  190. protected override void Dispose (bool disposing)
  191. {
  192. throw new NotImplementedException ();
  193. }
  194. protected virtual bool ShouldSerializeTableMappings ()
  195. {
  196. return true;
  197. }
  198. internal int FillInternal (DataTable dataTable, IDataReader dataReader)
  199. {
  200. if (dataReader.FieldCount == 0) {
  201. dataReader.Close ();
  202. return 0;
  203. }
  204. int count = 0;
  205. try {
  206. string tableName = SetupSchema (SchemaType.Mapped, dataTable.TableName);
  207. if (tableName != null) {
  208. dataTable.TableName = tableName;
  209. FillTable (dataTable, dataReader, 0, 0, ref count);
  210. }
  211. } finally {
  212. dataReader.Close ();
  213. }
  214. return count;
  215. }
  216. // this method builds the schema for a given datatable. it returns a int array with
  217. // "array[ordinal of datatable column] == index of source column in data reader".
  218. // each column in the datatable has a mapping to a specific column in the datareader,
  219. // the int array represents this match.
  220. internal int[] BuildSchema (IDataReader reader, DataTable table, SchemaType schemaType)
  221. {
  222. return BuildSchema (reader, table, schemaType, MissingSchemaAction,
  223. MissingMappingAction, TableMappings);
  224. }
  225. /// <summary>
  226. /// Creates or Modifies the schema of the given DataTable based on the schema of
  227. /// the reader and the arguments passed.
  228. /// </summary>
  229. internal static int[] BuildSchema (IDataReader reader, DataTable table,
  230. SchemaType schemaType,
  231. MissingSchemaAction missingSchAction,
  232. MissingMappingAction missingMapAction,
  233. DataTableMappingCollection dtMapping
  234. )
  235. {
  236. int readerIndex = 0;
  237. // FIXME : this fails if query has fewer columns than a table
  238. int[] mapping = new int[table.Columns.Count]; // mapping the reader indexes to the datatable indexes
  239. for(int i=0; i < mapping.Length; i++) {
  240. mapping[i] = -1;
  241. }
  242. ArrayList primaryKey = new ArrayList ();
  243. ArrayList sourceColumns = new ArrayList ();
  244. bool createPrimaryKey = true;
  245. DataTable schemaTable = reader.GetSchemaTable ();
  246. DataColumn ColumnNameCol = schemaTable.Columns["ColumnName"];
  247. DataColumn DataTypeCol = schemaTable.Columns["DataType"];
  248. DataColumn IsAutoIncrementCol = schemaTable.Columns["IsAutoIncrement"];
  249. DataColumn AllowDBNullCol = schemaTable.Columns["AllowDBNull"];
  250. DataColumn IsReadOnlyCol = schemaTable.Columns["IsReadOnly"];
  251. DataColumn IsKeyCol = schemaTable.Columns["IsKey"];
  252. DataColumn IsUniqueCol = schemaTable.Columns["IsUnique"];
  253. DataColumn ColumnSizeCol = schemaTable.Columns["ColumnSize"];
  254. foreach (DataRow schemaRow in schemaTable.Rows) {
  255. // generate a unique column name in the source table.
  256. string sourceColumnName;
  257. string realSourceColumnName ;
  258. if (ColumnNameCol == null || schemaRow.IsNull(ColumnNameCol) ||
  259. (string)schemaRow [ColumnNameCol] == String.Empty) {
  260. sourceColumnName = DefaultSourceColumnName;
  261. realSourceColumnName = DefaultSourceColumnName + "1";
  262. } else {
  263. sourceColumnName = (string) schemaRow [ColumnNameCol];
  264. realSourceColumnName = sourceColumnName;
  265. }
  266. for (int i = 1; sourceColumns.Contains (realSourceColumnName); i += 1)
  267. realSourceColumnName = String.Format ("{0}{1}", sourceColumnName, i);
  268. sourceColumns.Add(realSourceColumnName);
  269. // generate DataSetColumnName from DataTableMapping, if any
  270. string dsColumnName = realSourceColumnName;
  271. DataTableMapping tableMapping = null;
  272. //FIXME : The sourcetable name shud get passed as a parameter..
  273. int index = dtMapping.IndexOfDataSetTable (table.TableName);
  274. string srcTable = (index != -1 ? dtMapping[index].SourceTable : table.TableName);
  275. tableMapping = DataTableMappingCollection.GetTableMappingBySchemaAction (dtMapping, srcTable, table.TableName, missingMapAction);
  276. if (tableMapping != null) {
  277. table.TableName = tableMapping.DataSetTable;
  278. // check to see if the column mapping exists
  279. DataColumnMapping columnMapping = DataColumnMappingCollection.GetColumnMappingBySchemaAction(tableMapping.ColumnMappings, realSourceColumnName, missingMapAction);
  280. if (columnMapping != null) {
  281. Type columnType = (Type)schemaRow[DataTypeCol];
  282. DataColumn col =
  283. columnMapping.GetDataColumnBySchemaAction(
  284. table ,
  285. columnType,
  286. missingSchAction);
  287. if (col != null) {
  288. // if the column is not in the table - add it.
  289. if (table.Columns.IndexOf(col) == -1) {
  290. if (missingSchAction == MissingSchemaAction.Add
  291. || missingSchAction == MissingSchemaAction.AddWithKey)
  292. table.Columns.Add(col);
  293. int[] tmp = new int[mapping.Length + 1];
  294. Array.Copy(mapping,0,tmp,0,col.Ordinal);
  295. Array.Copy(mapping,col.Ordinal,tmp,col.Ordinal + 1,mapping.Length - col.Ordinal);
  296. mapping = tmp;
  297. }
  298. if (missingSchAction == MissingSchemaAction.AddWithKey) {
  299. object value = (AllowDBNullCol != null) ? schemaRow[AllowDBNullCol] : null;
  300. bool allowDBNull = value is bool ? (bool)value : true;
  301. value = (IsKeyCol != null) ? schemaRow[IsKeyCol] : null;
  302. bool isKey = value is bool ? (bool)value : false;
  303. value = (IsAutoIncrementCol != null) ? schemaRow[IsAutoIncrementCol] : null;
  304. bool isAutoIncrement = value is bool ? (bool)value : false;
  305. value = (IsReadOnlyCol != null) ? schemaRow[IsReadOnlyCol] : null;
  306. bool isReadOnly = value is bool ? (bool)value : false;
  307. value = (IsUniqueCol != null) ? schemaRow[IsUniqueCol] : null;
  308. bool isUnique = value is bool ? (bool)value : false;
  309. col.AllowDBNull = allowDBNull;
  310. // fill woth key info
  311. if (isAutoIncrement && DataColumn.CanAutoIncrement(columnType)) {
  312. col.AutoIncrement = true;
  313. if (!allowDBNull)
  314. col.AllowDBNull = false;
  315. }
  316. if (columnType == DbTypes.TypeOfString) {
  317. col.MaxLength = (ColumnSizeCol != null) ? (int)schemaRow[ColumnSizeCol] : 0;
  318. }
  319. if (isReadOnly)
  320. col.ReadOnly = true;
  321. if (!allowDBNull && (!isReadOnly || isKey))
  322. col.AllowDBNull = false;
  323. if (isUnique && !isKey && !columnType.IsArray) {
  324. col.Unique = true;
  325. if (!allowDBNull)
  326. col.AllowDBNull = false;
  327. }
  328. // This might not be set by all DataProviders
  329. bool isHidden = false;
  330. if (schemaTable.Columns.Contains ("IsHidden")) {
  331. value = schemaRow["IsHidden"];
  332. isHidden = ((value is bool) ? (bool)value : false);
  333. }
  334. if (isKey && !isHidden) {
  335. primaryKey.Add (col);
  336. if (allowDBNull)
  337. createPrimaryKey = false;
  338. }
  339. }
  340. // add the ordinal of the column as a key and the index of the column in the datareader as a value.
  341. mapping[col.Ordinal] = readerIndex++;
  342. }
  343. }
  344. }
  345. }
  346. if (primaryKey.Count > 0) {
  347. DataColumn[] colKey = (DataColumn[])(primaryKey.ToArray(typeof (DataColumn)));
  348. if (createPrimaryKey)
  349. table.PrimaryKey = colKey;
  350. else {
  351. UniqueConstraint uConstraint = new UniqueConstraint(colKey);
  352. for (int i = 0; i < table.Constraints.Count; i++) {
  353. if (table.Constraints[i].Equals(uConstraint)) {
  354. uConstraint = null;
  355. break;
  356. }
  357. }
  358. if (uConstraint != null)
  359. table.Constraints.Add(uConstraint);
  360. }
  361. }
  362. return mapping;
  363. }
  364. internal bool FillTable (DataTable dataTable, IDataReader dataReader, int startRecord, int maxRecords, ref int counter)
  365. {
  366. if (dataReader.FieldCount == 0)
  367. return false;
  368. int counterStart = counter;
  369. int[] mapping = BuildSchema (dataReader, dataTable, SchemaType.Mapped);
  370. int [] sortedMapping = new int [mapping.Length];
  371. int length = sortedMapping.Length;
  372. for (int i = 0; i < sortedMapping.Length; i++) {
  373. if (mapping [i] >= 0)
  374. sortedMapping [mapping [i]] = i;
  375. else
  376. sortedMapping [--length] = i;
  377. }
  378. for (int i = 0; i < startRecord; i++) {
  379. dataReader.Read ();
  380. }
  381. dataTable.BeginLoadData ();
  382. while (dataReader.Read () && (maxRecords == 0 || (counter - counterStart) < maxRecords)) {
  383. try {
  384. dataTable.LoadDataRow (dataReader, sortedMapping, length, AcceptChangesDuringFill);
  385. counter++;
  386. }
  387. catch (Exception e) {
  388. object[] readerArray = new object [dataReader.FieldCount];
  389. object[] tableArray = new object [mapping.Length];
  390. // we get the values from the datareader
  391. dataReader.GetValues (readerArray);
  392. // copy from datareader columns to table columns according to given mapping
  393. for (int i = 0; i < mapping.Length; i++) {
  394. if (mapping [i] >= 0) {
  395. tableArray [i] = readerArray [mapping [i]];
  396. }
  397. }
  398. FillErrorEventArgs args = CreateFillErrorEvent (dataTable, tableArray, e);
  399. OnFillErrorInternal (args);
  400. // if args.Continue is not set to true or if a handler is not set, rethrow the error..
  401. if(!args.Continue)
  402. throw e;
  403. }
  404. }
  405. dataTable.EndLoadData ();
  406. return true;
  407. }
  408. internal virtual void OnFillErrorInternal (FillErrorEventArgs value)
  409. {
  410. #if NET_2_0
  411. OnFillError (value);
  412. #endif
  413. }
  414. internal FillErrorEventArgs CreateFillErrorEvent (DataTable dataTable, object[] values, Exception e)
  415. {
  416. FillErrorEventArgs args = new FillErrorEventArgs (dataTable, values);
  417. args.Errors = e;
  418. args.Continue = false;
  419. return args;
  420. }
  421. internal string SetupSchema (SchemaType schemaType, string sourceTableName)
  422. {
  423. DataTableMapping tableMapping = null;
  424. if (schemaType == SchemaType.Mapped) {
  425. tableMapping = DataTableMappingCollection.GetTableMappingBySchemaAction (TableMappings, sourceTableName, sourceTableName, MissingMappingAction);
  426. if (tableMapping != null)
  427. return tableMapping.DataSetTable;
  428. return null;
  429. } else
  430. return sourceTableName;
  431. }
  432. internal int FillInternal (DataSet dataSet, string srcTable, IDataReader dataReader, int startRecord, int maxRecords)
  433. {
  434. if (dataSet == null)
  435. throw new ArgumentNullException ("DataSet");
  436. if (startRecord < 0)
  437. throw new ArgumentException ("The startRecord parameter was less than 0.");
  438. if (maxRecords < 0)
  439. throw new ArgumentException ("The maxRecords parameter was less than 0.");
  440. DataTable dataTable = null;
  441. int resultIndex = 0;
  442. int count = 0;
  443. try {
  444. string tableName = srcTable;
  445. do {
  446. // Non-resultset queries like insert, delete or update aren't processed.
  447. if (dataReader.FieldCount != -1) {
  448. tableName = SetupSchema (SchemaType.Mapped, tableName);
  449. if (tableName != null) {
  450. // check if the table exists in the dataset
  451. if (dataSet.Tables.Contains (tableName))
  452. // get the table from the dataset
  453. dataTable = dataSet.Tables [tableName];
  454. else {
  455. // Do not create schema if MissingSchemAction is set to Ignore
  456. if (this.MissingSchemaAction == MissingSchemaAction.Ignore)
  457. continue;
  458. dataTable = dataSet.Tables.Add (tableName);
  459. }
  460. if (!FillTable (dataTable, dataReader, startRecord, maxRecords, ref count))
  461. continue;
  462. tableName = String.Format ("{0}{1}", srcTable, ++resultIndex);
  463. startRecord = 0;
  464. maxRecords = 0;
  465. }
  466. }
  467. } while (dataReader.NextResult ());
  468. } finally {
  469. dataReader.Close ();
  470. }
  471. return count;
  472. }
  473. #if NET_2_0
  474. public virtual int Fill (DataSet dataSet)
  475. {
  476. throw new NotSupportedException();
  477. }
  478. protected virtual int Fill (DataTable dataTable, IDataReader dataReader)
  479. {
  480. return FillInternal (dataTable, dataReader);
  481. }
  482. protected virtual int Fill (DataTable[] dataTables, IDataReader dataReader, int startRecord, int maxRecords)
  483. {
  484. int count = 0;
  485. if (dataReader.IsClosed)
  486. return 0;
  487. if (startRecord < 0)
  488. throw new ArgumentException ("The startRecord parameter was less than 0.");
  489. if (maxRecords < 0)
  490. throw new ArgumentException ("The maxRecords parameter was less than 0.");
  491. try {
  492. foreach (DataTable dataTable in dataTables) {
  493. string tableName = SetupSchema (SchemaType.Mapped, dataTable.TableName);
  494. if (tableName != null) {
  495. dataTable.TableName = tableName;
  496. FillTable (dataTable, dataReader, 0, 0, ref count);
  497. }
  498. }
  499. } finally {
  500. dataReader.Close ();
  501. }
  502. return count;
  503. }
  504. protected virtual int Fill (DataSet dataSet, string srcTable, IDataReader dataReader, int startRecord, int maxRecords)
  505. {
  506. return FillInternal (dataSet, srcTable, dataReader, startRecord, maxRecords);
  507. }
  508. [MonoTODO]
  509. protected virtual DataTable FillSchema (DataTable dataTable, SchemaType schemaType, IDataReader dataReader)
  510. {
  511. throw new NotImplementedException ();
  512. }
  513. [MonoTODO]
  514. protected virtual DataTable[] FillSchema (DataSet dataSet, SchemaType schemaType, string srcTable, IDataReader dataReader)
  515. {
  516. throw new NotImplementedException ();
  517. }
  518. public virtual DataTable[] FillSchema (DataSet dataSet, SchemaType schemaType)
  519. {
  520. throw new NotSupportedException ();
  521. }
  522. [MonoTODO]
  523. [EditorBrowsable (EditorBrowsableState.Advanced)]
  524. public virtual IDataParameter[] GetFillParameters ()
  525. {
  526. throw new NotImplementedException ();
  527. }
  528. protected bool HasTableMappings ()
  529. {
  530. return (TableMappings.Count != 0);
  531. }
  532. protected virtual void OnFillError (FillErrorEventArgs value)
  533. {
  534. if (FillError != null)
  535. FillError (this, value);
  536. }
  537. [EditorBrowsable (EditorBrowsableState.Never)]
  538. public void ResetFillLoadOption ()
  539. {
  540. //FIXME: what else ??
  541. FillLoadOption = LoadOption.OverwriteChanges;
  542. }
  543. [EditorBrowsable (EditorBrowsableState.Never)]
  544. public virtual bool ShouldSerializeAcceptChangesDuringFill ()
  545. {
  546. return true;
  547. }
  548. [EditorBrowsable (EditorBrowsableState.Never)]
  549. public virtual bool ShouldSerializeFillLoadOption ()
  550. {
  551. return false;
  552. }
  553. [MonoTODO]
  554. public virtual int Update (DataSet dataSet)
  555. {
  556. throw new NotImplementedException ();
  557. }
  558. #else
  559. public abstract int Fill (DataSet dataSet);
  560. public abstract DataTable[] FillSchema (DataSet dataSet, SchemaType schemaType);
  561. public abstract IDataParameter[] GetFillParameters ();
  562. public abstract int Update (DataSet dataSet);
  563. #endif
  564. #endregion
  565. }
  566. }