2002-04-23 Rodrigo Moya <rodrigo@ximian.com>
[mono.git] / mcs / class / System.Data / System.Data.Common / DataAdapter.cs
1 //
2 // System.Data.Common.DataAdapter
3 //
4 // Author:
5 //   Rodrigo Moya (rodrigo@ximian.com)
6 //
7 // (C) Ximian, Inc
8 //
9
10 using System.ComponentModel;
11 using System.Data;
12
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                 private bool acceptChangesDuringFill;
21                 private bool continueUpdateOnError;
22                 private MissingMappingAction missingMappingAction;
23                 private MissingSchemaAction missingSchemaAction;
24                 private DataTableMappingCollection tableMappings;
25
26                 protected DataAdapter () {
27                         acceptChangesDuringFill = false;
28                         continueUpdateOnError = false;
29                         missingMappingAction = MissingMappingAction.Error;
30                         missingSchemaAction = MissingSchemaAction.Error;
31                         tableMappings = null;
32                 }
33                 
34                 public abstract int Fill (DataSet dataSet);
35
36                 public abstract DataTable[] FillSchema (DataSet dataSet,
37                                                         SchemaType schemaType);
38
39                 public abstract IDataParameter[] GetFillParameters ();
40
41                 public abstract int Update (DataSet dataSet);
42
43                 protected virtual DataAdapter CloneInternals () {
44                 }
45
46                 protected virtual DataTableMappingCollection CreateTableMappings () {
47                 }
48
49                 protected virtual bool ShouldSerializeTableMappings () {
50                 }
51                 
52                 public bool AcceptChangesDuringFill {
53                         get {
54                                 return acceptChangesDuringFill;
55                         }
56                         set {
57                                 acceptChangesDuringFill = value;
58                         }
59                 }
60
61                 public bool ContinueUpdateOnError {
62                         get {
63                                 return continueUpdateOnError;
64                         }
65                         set {
66                                 continueUpdateOnError = value;
67                         }
68                 }
69
70                 public MissingMappingAction MissingMappingAction {
71                         get {
72                                 return missingMappingAction;
73                         }
74                         set {
75                                 missingMappingAction = value;
76                         }
77                 }
78
79                 public MissingSchemaAction MissingSchemaAction {
80                         get {
81                                 return missingSchemaAction;
82                         }
83                         set {
84                                 missingSchemaAction = value;
85                         }
86                 }
87
88                 public DataTableMappingCollection TableMappings {
89                         get {
90                                 if (tableMappings == null)
91                                         tableMappings = CreateTableMappings ();
92                                 return tableMappings;
93                         }
94                 }
95         }
96 }