2002-04-17 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.Data;
11
12 namespace System.Data.Common
13 {
14         /// <summary>
15         /// Represents a set of data commands and a database connection that are used to fill the DataSet and update the data source.
16         /// </summary>
17         public abstract class DataAdapter : Component, IDataAdapter
18         {
19                 private bool acceptChangesDuringFill;
20                 private bool continueUpdateOnError;
21                 private MissingMappingAction missingMappingAction;
22                 private MissingSchemaAction missingSchemaAction;
23                 private DataTableMappingCollection tableMappings;
24
25                 protected DataAdapter () {
26                         acceptChangesDuringFill = false;
27                         continueUpdateOnError = false;
28                         missingMappingAction = MissingMappingAction.Error;
29                         missingSchemaAction = MissingSchemaAction.Error;
30                         tableMappings = null;
31                 }
32                 
33                 public abstract int Fill (DataSet dataSet);
34
35                 public abstract DataTable[] FillSchema (DataSet dataSet,
36                                                         SchemaType schemaType);
37
38                 public abstract IDataParameter[] GetFillParameters ();
39
40                 public abstract int Update (DataSet dataSet);
41
42                 protected virtual DataAdapter CloneInternals () {
43                 }
44
45                 protected virtual DataTableMappingCollection CreateTableMappings () {
46                 }
47
48                 protected virtual bool ShouldSerializeTableMappings () {
49                 }
50                 
51                 public bool AcceptChangesDuringFill {
52                         get {
53                                 return acceptChangesDuringFill;
54                         }
55                         set {
56                                 acceptChangesDuringFill = value;
57                         }
58                 }
59
60                 public bool ContinueUpdateOnError {
61                         get {
62                                 return continueUpdateOnError;
63                         }
64                         set {
65                                 continueUpdateOnError = value;
66                         }
67                 }
68
69                 public MissingMappingAction MissingMappingAction {
70                         get {
71                                 return missingMappingAction;
72                         }
73                         set {
74                                 missingMappingAction = value;
75                         }
76                 }
77
78                 public MissingSchemaAction MissingSchemaAction {
79                         get {
80                                 return missingSchemaAction;
81                         }
82                         set {
83                                 missingSchemaAction = value;
84                         }
85                 }
86
87                 public DataTableMappingCollection TableMappings {
88                         get {
89                                 if (tableMappings == null)
90                                         tableMappings = CreateTableMappings ();
91                                 return tableMappings;
92                         }
93                 }
94         }
95 }