DataAdapter.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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) 2002 Tim Coleman
  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. #endregion
  27. #region Constructors
  28. protected DataAdapter ()
  29. {
  30. acceptChangesDuringFill = true;
  31. continueUpdateOnError = false;
  32. missingMappingAction = MissingMappingAction.Passthrough;
  33. missingSchemaAction = MissingSchemaAction.Add;
  34. tableMappings = new DataTableMappingCollection ();
  35. }
  36. #endregion
  37. #region Properties
  38. [DataCategory ("Fill")]
  39. [DataSysDescription ("Whether or not Fill will call DataRow.AcceptChanges.")]
  40. [DefaultValue (true)]
  41. public bool AcceptChangesDuringFill {
  42. get { return acceptChangesDuringFill; }
  43. set { acceptChangesDuringFill = value; }
  44. }
  45. [DataCategory ("Update")]
  46. [DataSysDescription ("Whether or not to continue to the next DataRow when the Update events, RowUpdating and RowUpdated, Status is UpdateStatus.ErrorsOccurred.")]
  47. [DefaultValue (false)]
  48. public bool ContinueUpdateOnError {
  49. get { return continueUpdateOnError; }
  50. set { continueUpdateOnError = value; }
  51. }
  52. ITableMappingCollection IDataAdapter.TableMappings {
  53. get { return TableMappings; }
  54. }
  55. [DataCategory ("Mapping")]
  56. [DataSysDescription ("The action taken when a table or column in the TableMappings is missing.")]
  57. [DefaultValue (MissingMappingAction.Passthrough)]
  58. public MissingMappingAction MissingMappingAction {
  59. get { return missingMappingAction; }
  60. set { missingMappingAction = value; }
  61. }
  62. [DataCategory ("Mapping")]
  63. [DataSysDescription ("The action taken when a table or column in the DataSet is missing.")]
  64. [DefaultValue (MissingSchemaAction.Add)]
  65. public MissingSchemaAction MissingSchemaAction {
  66. get { return missingSchemaAction; }
  67. set { missingSchemaAction = value; }
  68. }
  69. [DataCategory ("Mapping")]
  70. [DataSysDescription ("How to map source table to DataSet table.")]
  71. [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
  72. public DataTableMappingCollection TableMappings {
  73. get { return tableMappings; }
  74. }
  75. #endregion
  76. #region Methods
  77. #if NET_1_1
  78. [Obsolete ("Use the protected constructor instead", false)]
  79. #endif
  80. [MonoTODO]
  81. protected virtual DataAdapter CloneInternals ()
  82. {
  83. throw new NotImplementedException ();
  84. }
  85. protected virtual DataTableMappingCollection CreateTableMappings ()
  86. {
  87. tableMappings = new DataTableMappingCollection ();
  88. return tableMappings;
  89. }
  90. [MonoTODO]
  91. protected override void Dispose (bool disposing)
  92. {
  93. throw new NotImplementedException ();
  94. }
  95. public abstract int Fill (DataSet dataSet);
  96. public abstract DataTable[] FillSchema (DataSet dataSet, SchemaType schemaType);
  97. public abstract IDataParameter[] GetFillParameters ();
  98. [MonoTODO]
  99. protected virtual bool ShouldSerializeTableMappings ()
  100. {
  101. throw new NotImplementedException ();
  102. }
  103. public abstract int Update (DataSet dataSet);
  104. #endregion
  105. }
  106. }