DataAdapter.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  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 !NET_2_0
  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 { fillLoadOption = value; }
  123. }
  124. #endif
  125. ITableMappingCollection IDataAdapter.TableMappings {
  126. get { return TableMappings; }
  127. }
  128. [DataCategory ("Mapping")]
  129. #if !NET_2_0
  130. [DataSysDescription ("The action taken when a table or column in the TableMappings is missing.")]
  131. #endif
  132. [DefaultValue (MissingMappingAction.Passthrough)]
  133. public MissingMappingAction MissingMappingAction {
  134. get { return missingMappingAction; }
  135. set {
  136. if (!Enum.IsDefined (typeof (MissingMappingAction), value))
  137. throw ExceptionHelper.InvalidEnumValueException ("MissingMappingAction", value);
  138. missingMappingAction = value;
  139. }
  140. }
  141. [DataCategory ("Mapping")]
  142. #if !NET_2_0
  143. [DataSysDescription ("The action taken when a table or column in the DataSet is missing.")]
  144. #endif
  145. [DefaultValue (MissingSchemaAction.Add)]
  146. public MissingSchemaAction MissingSchemaAction {
  147. get { return missingSchemaAction; }
  148. set {
  149. if (!Enum.IsDefined (typeof (MissingSchemaAction), value))
  150. throw ExceptionHelper.InvalidEnumValueException ("MissingSchemaAction", value);
  151. missingSchemaAction = value;
  152. }
  153. }
  154. #if NET_2_0
  155. [DefaultValue (false)]
  156. public virtual bool ReturnProviderSpecificTypes {
  157. get { return returnProviderSpecificTypes; }
  158. set { returnProviderSpecificTypes = value; }
  159. }
  160. #endif
  161. [DataCategory ("Mapping")]
  162. #if !NET_2_0
  163. [DataSysDescription ("How to map source table to DataSet table.")]
  164. #endif
  165. [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
  166. public DataTableMappingCollection TableMappings {
  167. get { return tableMappings; }
  168. }
  169. #endregion
  170. #region Events
  171. #if NET_2_0
  172. public event FillErrorEventHandler FillError;
  173. #endif
  174. #endregion
  175. #region Methods
  176. #if !NET_1_0
  177. [Obsolete ("Use the protected constructor instead", false)]
  178. #endif
  179. [MonoTODO]
  180. protected virtual DataAdapter CloneInternals ()
  181. {
  182. throw new NotImplementedException ();
  183. }
  184. protected virtual DataTableMappingCollection CreateTableMappings ()
  185. {
  186. return new DataTableMappingCollection ();
  187. }
  188. [MonoTODO]
  189. protected override void Dispose (bool disposing)
  190. {
  191. throw new NotImplementedException ();
  192. }
  193. protected virtual bool ShouldSerializeTableMappings ()
  194. {
  195. return true;
  196. }
  197. internal int FillInternal (DataTable dataTable, IDataReader dataReader)
  198. {
  199. if (dataReader.FieldCount == 0) {
  200. dataReader.Close ();
  201. return 0;
  202. }
  203. int count = 0;
  204. try {
  205. string tableName = SetupSchema (SchemaType.Mapped, dataTable.TableName);
  206. if (tableName != null) {
  207. dataTable.TableName = tableName;
  208. FillTable (dataTable, dataReader, 0, 0, ref count);
  209. }
  210. } finally {
  211. dataReader.Close ();
  212. }
  213. return count;
  214. }
  215. // this method builds the schema for a given datatable. it returns a int array with
  216. // "array[ordinal of datatable column] == index of source column in data reader".
  217. // each column in the datatable has a mapping to a specific column in the datareader,
  218. // the int array represents this match.
  219. internal int[] BuildSchema (IDataReader reader, DataTable table, SchemaType schemaType)
  220. {
  221. return BuildSchema (reader, table, schemaType, MissingSchemaAction,
  222. MissingMappingAction, TableMappings);
  223. }
  224. /// <summary>
  225. /// Creates or Modifies the schema of the given DataTable based on the schema of
  226. /// the reader and the arguments passed.
  227. /// </summary>
  228. internal static int[] BuildSchema (IDataReader reader,
  229. 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. }
  263. else {
  264. sourceColumnName = (string) schemaRow [ColumnNameCol];
  265. realSourceColumnName = sourceColumnName;
  266. }
  267. for (int i = 1; sourceColumns.Contains (realSourceColumnName); i += 1)
  268. realSourceColumnName = String.Format ("{0}{1}", sourceColumnName, i);
  269. sourceColumns.Add(realSourceColumnName);
  270. // generate DataSetColumnName from DataTableMapping, if any
  271. string dsColumnName = realSourceColumnName;
  272. DataTableMapping tableMapping = null;
  273. //FIXME : The sourcetable name shud get passed as a parameter..
  274. int index = dtMapping.IndexOfDataSetTable (table.TableName);
  275. string srcTable = (index != -1 ? dtMapping[index].SourceTable : table.TableName);
  276. tableMapping = DataTableMappingCollection.GetTableMappingBySchemaAction (dtMapping, srcTable, table.TableName, missingMapAction);
  277. if (tableMapping != null)
  278. {
  279. table.TableName = tableMapping.DataSetTable;
  280. // check to see if the column mapping exists
  281. DataColumnMapping columnMapping = DataColumnMappingCollection.GetColumnMappingBySchemaAction(tableMapping.ColumnMappings, realSourceColumnName, missingMapAction);
  282. if (columnMapping != null)
  283. {
  284. Type columnType = (Type)schemaRow[DataTypeCol];
  285. DataColumn col =
  286. columnMapping.GetDataColumnBySchemaAction(
  287. table ,
  288. columnType,
  289. missingSchAction);
  290. if (col != null)
  291. {
  292. // if the column is not in the table - add it.
  293. if (table.Columns.IndexOf(col) == -1)
  294. {
  295. if (missingSchAction == MissingSchemaAction.Add
  296. || missingSchAction == MissingSchemaAction.AddWithKey)
  297. table.Columns.Add(col);
  298. int[] tmp = new int[mapping.Length + 1];
  299. Array.Copy(mapping,0,tmp,0,col.Ordinal);
  300. Array.Copy(mapping,col.Ordinal,tmp,col.Ordinal + 1,mapping.Length - col.Ordinal);
  301. mapping = tmp;
  302. }
  303. if (missingSchAction == MissingSchemaAction.AddWithKey) {
  304. object value = (AllowDBNullCol != null) ? schemaRow[AllowDBNullCol] : null;
  305. bool allowDBNull = value is bool ? (bool)value : true;
  306. value = (IsKeyCol != null) ? schemaRow[IsKeyCol] : null;
  307. bool isKey = value is bool ? (bool)value : false;
  308. value = (IsAutoIncrementCol != null) ? schemaRow[IsAutoIncrementCol] : null;
  309. bool isAutoIncrement = value is bool ? (bool)value : false;
  310. value = (IsReadOnlyCol != null) ? schemaRow[IsReadOnlyCol] : null;
  311. bool isReadOnly = value is bool ? (bool)value : false;
  312. value = (IsUniqueCol != null) ? schemaRow[IsUniqueCol] : null;
  313. bool isUnique = value is bool ? (bool)value : false;
  314. col.AllowDBNull = allowDBNull;
  315. // fill woth key info
  316. if (isAutoIncrement && DataColumn.CanAutoIncrement(columnType)) {
  317. col.AutoIncrement = true;
  318. if (!allowDBNull)
  319. col.AllowDBNull = false;
  320. }
  321. if (columnType == DbTypes.TypeOfString) {
  322. col.MaxLength = (ColumnSizeCol != null) ? (int)schemaRow[ColumnSizeCol] : 0;
  323. }
  324. if (isReadOnly)
  325. col.ReadOnly = true;
  326. if (!allowDBNull && (!isReadOnly || isKey))
  327. col.AllowDBNull = false;
  328. if (isUnique && !isKey && !columnType.IsArray) {
  329. col.Unique = true;
  330. if (!allowDBNull)
  331. col.AllowDBNull = false;
  332. }
  333. // This might not be set by all DataProviders
  334. bool isHidden = false;
  335. if (schemaTable.Columns.Contains ("IsHidden")) {
  336. value = schemaRow["IsHidden"];
  337. isHidden = ((value is bool) ? (bool)value : false);
  338. }
  339. if (isKey && !isHidden) {
  340. primaryKey.Add (col);
  341. if (allowDBNull)
  342. createPrimaryKey = false;
  343. }
  344. }
  345. // add the ordinal of the column as a key and the index of the column in the datareader as a value.
  346. mapping[col.Ordinal] = readerIndex++;
  347. }
  348. }
  349. }
  350. }
  351. if (primaryKey.Count > 0) {
  352. DataColumn[] colKey = (DataColumn[])(primaryKey.ToArray(typeof (DataColumn)));
  353. if (createPrimaryKey)
  354. table.PrimaryKey = colKey;
  355. else {
  356. UniqueConstraint uConstraint = new UniqueConstraint(colKey);
  357. for (int i = 0; i < table.Constraints.Count; i++) {
  358. if (table.Constraints[i].Equals(uConstraint)) {
  359. uConstraint = null;
  360. break;
  361. }
  362. }
  363. if (uConstraint != null)
  364. table.Constraints.Add(uConstraint);
  365. }
  366. }
  367. return mapping;
  368. }
  369. internal bool FillTable (DataTable dataTable, IDataReader dataReader, int startRecord, int maxRecords, ref int counter)
  370. {
  371. if (dataReader.FieldCount == 0)
  372. return false;
  373. int counterStart = counter;
  374. int[] mapping = BuildSchema (dataReader, dataTable, SchemaType.Mapped);
  375. int [] sortedMapping = new int [mapping.Length];
  376. int length = sortedMapping.Length;
  377. for (int i = 0; i < sortedMapping.Length; i++) {
  378. if (mapping [i] >= 0)
  379. sortedMapping [mapping [i]] = i;
  380. else
  381. sortedMapping [--length] = i;
  382. }
  383. for (int i = 0; i < startRecord; i++) {
  384. dataReader.Read ();
  385. }
  386. dataTable.BeginLoadData ();
  387. while (dataReader.Read () && (maxRecords == 0 || (counter - counterStart) < maxRecords)) {
  388. try {
  389. dataTable.LoadDataRow (dataReader, sortedMapping, length, AcceptChangesDuringFill);
  390. counter++;
  391. }
  392. catch (Exception e) {
  393. object[] readerArray = new object [dataReader.FieldCount];
  394. object[] tableArray = new object [mapping.Length];
  395. // we get the values from the datareader
  396. dataReader.GetValues (readerArray);
  397. // copy from datareader columns to table columns according to given mapping
  398. for (int i = 0; i < mapping.Length; i++) {
  399. if (mapping [i] >= 0) {
  400. tableArray [i] = readerArray [mapping [i]];
  401. }
  402. }
  403. FillErrorEventArgs args = CreateFillErrorEvent (dataTable, tableArray, e);
  404. OnFillErrorInternal (args);
  405. // if args.Continue is not set to true or if a handler is not set, rethrow the error..
  406. if(!args.Continue)
  407. throw e;
  408. }
  409. }
  410. dataTable.EndLoadData ();
  411. return true;
  412. }
  413. internal virtual void OnFillErrorInternal (FillErrorEventArgs value)
  414. {
  415. #if NET_2_0
  416. OnFillError (value);
  417. #endif
  418. }
  419. internal FillErrorEventArgs CreateFillErrorEvent (DataTable dataTable, object[] values, Exception e)
  420. {
  421. FillErrorEventArgs args = new FillErrorEventArgs (dataTable, values);
  422. args.Errors = e;
  423. args.Continue = false;
  424. return args;
  425. }
  426. internal string SetupSchema (SchemaType schemaType, string sourceTableName)
  427. {
  428. DataTableMapping tableMapping = null;
  429. if (schemaType == SchemaType.Mapped)
  430. {
  431. tableMapping = DataTableMappingCollection.GetTableMappingBySchemaAction (TableMappings, sourceTableName, sourceTableName, MissingMappingAction);
  432. if (tableMapping != null)
  433. return tableMapping.DataSetTable;
  434. return null;
  435. }
  436. else
  437. return sourceTableName;
  438. }
  439. internal int FillInternal (DataSet dataSet, string srcTable, IDataReader dataReader, int startRecord, int maxRecords)
  440. {
  441. if (dataSet == null)
  442. throw new ArgumentNullException ("DataSet");
  443. if (startRecord < 0)
  444. throw new ArgumentException ("The startRecord parameter was less than 0.");
  445. if (maxRecords < 0)
  446. throw new ArgumentException ("The maxRecords parameter was less than 0.");
  447. DataTable dataTable = null;
  448. int resultIndex = 0;
  449. int count = 0;
  450. try {
  451. string tableName = srcTable;
  452. do {
  453. // Non-resultset queries like insert, delete or update aren't processed.
  454. if (dataReader.FieldCount != -1) {
  455. tableName = SetupSchema (SchemaType.Mapped, tableName);
  456. if (tableName != null) {
  457. // check if the table exists in the dataset
  458. if (dataSet.Tables.Contains (tableName))
  459. // get the table from the dataset
  460. dataTable = dataSet.Tables [tableName];
  461. else {
  462. // Do not create schema if MissingSchemAction is set to Ignore
  463. if (this.MissingSchemaAction == MissingSchemaAction.Ignore)
  464. continue;
  465. dataTable = dataSet.Tables.Add (tableName);
  466. }
  467. if (!FillTable (dataTable, dataReader, startRecord, maxRecords, ref count)) {
  468. continue;
  469. }
  470. tableName = String.Format ("{0}{1}", srcTable, ++resultIndex);
  471. startRecord = 0;
  472. maxRecords = 0;
  473. }
  474. }
  475. } while (dataReader.NextResult ());
  476. }
  477. finally {
  478. dataReader.Close ();
  479. }
  480. return count;
  481. }
  482. #if NET_2_0
  483. public virtual int Fill (DataSet dataSet)
  484. {
  485. throw new NotSupportedException();
  486. }
  487. protected virtual int Fill (DataTable dataTable, IDataReader dataReader)
  488. {
  489. return FillInternal (dataTable, dataReader);
  490. }
  491. protected virtual int Fill (DataTable[] dataTables, IDataReader dataReader, int startRecord, int maxRecords)
  492. {
  493. int count = 0;
  494. if (dataReader.IsClosed)
  495. return 0;
  496. if (startRecord < 0)
  497. throw new ArgumentException ("The startRecord parameter was less than 0.");
  498. if (maxRecords < 0)
  499. throw new ArgumentException ("The maxRecords parameter was less than 0.");
  500. try {
  501. foreach (DataTable dataTable in dataTables) {
  502. string tableName = SetupSchema (SchemaType.Mapped, dataTable.TableName);
  503. if (tableName != null) {
  504. dataTable.TableName = tableName;
  505. FillTable (dataTable, dataReader, 0, 0, ref count);
  506. }
  507. }
  508. } finally {
  509. dataReader.Close ();
  510. }
  511. return count;
  512. }
  513. protected virtual int Fill (DataSet dataSet, string srcTable, IDataReader dataReader, int startRecord, int maxRecords)
  514. {
  515. return FillInternal (dataSet, srcTable, dataReader, startRecord, maxRecords);
  516. }
  517. [MonoTODO]
  518. protected virtual DataTable FillSchema (DataTable dataTable, SchemaType schemaType, IDataReader dataReader)
  519. {
  520. throw new NotImplementedException ();
  521. }
  522. [MonoTODO]
  523. protected virtual DataTable[] FillSchema (DataSet dataSet, SchemaType schemaType, string srcTable, IDataReader dataReader)
  524. {
  525. throw new NotImplementedException ();
  526. }
  527. public virtual DataTable[] FillSchema (DataSet dataSet, SchemaType schemaType)
  528. {
  529. throw new NotSupportedException ();
  530. }
  531. [MonoTODO]
  532. [EditorBrowsable (EditorBrowsableState.Advanced)]
  533. public virtual IDataParameter[] GetFillParameters ()
  534. {
  535. throw new NotImplementedException ();
  536. }
  537. protected bool HasTableMappings ()
  538. {
  539. return (TableMappings.Count != 0);
  540. }
  541. protected virtual void OnFillError (FillErrorEventArgs value)
  542. {
  543. if (FillError != null)
  544. FillError (this, value);
  545. }
  546. [EditorBrowsable (EditorBrowsableState.Never)]
  547. public void ResetFillLoadOption ()
  548. {
  549. //FIXME: what else ??
  550. FillLoadOption = LoadOption.OverwriteChanges;
  551. }
  552. [EditorBrowsable (EditorBrowsableState.Never)]
  553. public virtual bool ShouldSerializeAcceptChangesDuringFill ()
  554. {
  555. return true;
  556. }
  557. [EditorBrowsable (EditorBrowsableState.Never)]
  558. public virtual bool ShouldSerializeFillLoadOption ()
  559. {
  560. return false;
  561. }
  562. [MonoTODO]
  563. public virtual int Update (DataSet dataSet)
  564. {
  565. throw new NotImplementedException ();
  566. }
  567. #else
  568. public abstract int Fill (DataSet dataSet);
  569. public abstract DataTable[] FillSchema (DataSet dataSet, SchemaType schemaType);
  570. public abstract IDataParameter[] GetFillParameters ();
  571. public abstract int Update (DataSet dataSet);
  572. #endif
  573. #endregion
  574. }
  575. }