(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / Mono.Data.PostgreSqlClient / Mono.Data.PostgreSqlClient / PgSqlDataAdapter.cs
blob1873c5c26f1420ee16b71c0ebe16043a73fbadc9
1 //
2 // Mono.Data.PostgreSqlClient.PgSqlDataAdapter.cs
3 //
4 // Author:
5 // Rodrigo Moya (rodrigo@ximian.com)
6 // Daniel Morgan (danmorg@sc.rr.com)
7 // Tim Coleman (tim@timcoleman.com)
8 //
9 // (C) Ximian, Inc 2002
10 // Copyright (C) 2002 Tim Coleman
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.
34 using System;
35 using System.ComponentModel;
36 using System.Data;
37 using System.Data.Common;
39 namespace Mono.Data.PostgreSqlClient
41 /// <summary>
42 /// Represents a set of command-related properties that are used
43 /// to fill the DataSet and update a data source, all this
44 /// from a SQL database.
45 /// </summary>
46 public sealed class PgSqlDataAdapter : DbDataAdapter, IDbDataAdapter
48 #region Fields
50 PgSqlCommand deleteCommand;
51 PgSqlCommand insertCommand;
52 PgSqlCommand selectCommand;
53 PgSqlCommand updateCommand;
55 static readonly object EventRowUpdated = new object();
56 static readonly object EventRowUpdating = new object();
58 #endregion
60 #region Constructors
62 public PgSqlDataAdapter ()
63 : this (new PgSqlCommand ())
67 public PgSqlDataAdapter (PgSqlCommand selectCommand)
69 DeleteCommand = new PgSqlCommand ();
70 InsertCommand = new PgSqlCommand ();
71 SelectCommand = selectCommand;
72 UpdateCommand = new PgSqlCommand ();
75 public PgSqlDataAdapter (string selectCommandText, PgSqlConnection selectConnection)
76 : this (new PgSqlCommand (selectCommandText, selectConnection))
80 public PgSqlDataAdapter (string selectCommandText, string selectConnectionString)
81 : this (selectCommandText, new PgSqlConnection (selectConnectionString))
85 #endregion
87 #region Properties
89 public PgSqlCommand DeleteCommand {
90 get {
91 return deleteCommand;
93 set {
94 deleteCommand = value;
98 public PgSqlCommand InsertCommand {
99 get {
100 return insertCommand;
102 set {
103 insertCommand = value;
107 public PgSqlCommand SelectCommand {
108 get {
109 return selectCommand;
111 set {
112 selectCommand = value;
116 public PgSqlCommand UpdateCommand {
117 get {
118 return updateCommand;
120 set {
121 updateCommand = value;
125 IDbCommand IDbDataAdapter.DeleteCommand {
126 get { return DeleteCommand; }
127 set {
128 if (!(value is PgSqlCommand))
129 throw new ArgumentException ();
130 DeleteCommand = (PgSqlCommand)value;
134 IDbCommand IDbDataAdapter.InsertCommand {
135 get { return InsertCommand; }
136 set {
137 if (!(value is PgSqlCommand))
138 throw new ArgumentException ();
139 InsertCommand = (PgSqlCommand)value;
143 IDbCommand IDbDataAdapter.SelectCommand {
144 get { return SelectCommand; }
145 set {
146 if (!(value is PgSqlCommand))
147 throw new ArgumentException ();
148 SelectCommand = (PgSqlCommand)value;
152 IDbCommand IDbDataAdapter.UpdateCommand {
153 get { return UpdateCommand; }
154 set {
155 if (!(value is PgSqlCommand))
156 throw new ArgumentException ();
157 UpdateCommand = (PgSqlCommand)value;
162 ITableMappingCollection IDataAdapter.TableMappings {
163 get { return TableMappings; }
166 #endregion // Properties
168 #region Methods
170 protected override RowUpdatedEventArgs CreateRowUpdatedEvent (DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
172 return new PgSqlRowUpdatedEventArgs (dataRow, command, statementType, tableMapping);
176 protected override RowUpdatingEventArgs CreateRowUpdatingEvent (DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
178 return new PgSqlRowUpdatingEventArgs (dataRow, command, statementType, tableMapping);
181 protected override void OnRowUpdated (RowUpdatedEventArgs value)
183 PgSqlRowUpdatedEventHandler handler = (PgSqlRowUpdatedEventHandler) Events[EventRowUpdated];
184 if ((handler != null) && (value is PgSqlRowUpdatedEventArgs))
185 handler(this, (PgSqlRowUpdatedEventArgs) value);
188 protected override void OnRowUpdating (RowUpdatingEventArgs value)
190 PgSqlRowUpdatingEventHandler handler = (PgSqlRowUpdatingEventHandler) Events[EventRowUpdating];
191 if ((handler != null) && (value is PgSqlRowUpdatingEventArgs))
192 handler(this, (PgSqlRowUpdatingEventArgs) value);
195 #endregion // Methods
197 #region Events and Delegates
199 public event PgSqlRowUpdatedEventHandler RowUpdated {
200 add { Events.AddHandler (EventRowUpdated, value); }
201 remove { Events.RemoveHandler (EventRowUpdated, value); }
204 public event PgSqlRowUpdatingEventHandler RowUpdating {
205 add { Events.AddHandler (EventRowUpdating, value); }
206 remove { Events.RemoveHandler (EventRowUpdating, value); }
209 #endregion // Events and Delegates