1 // created on 1/8/2002 at 23:02
3 // Npgsql.NpgsqlDataAdapter.cs
6 // Francisco Jr. (fxjrlists@yahoo.com.br)
8 // Copyright (C) 2002 The Npgsql Development Team
9 // npgsql-general@gborg.postgresql.org
10 // http://gborg.postgresql.org/project/npgsql/projdisplay.php
13 // This library is free software; you can redistribute it and/or
14 // modify it under the terms of the GNU Lesser General Public
15 // License as published by the Free Software Foundation; either
16 // version 2.1 of the License, or (at your option) any later version.
18 // This library is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 // Lesser General Public License for more details.
23 // You should have received a copy of the GNU Lesser General Public
24 // License along with this library; if not, write to the Free Software
25 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 using System.Data.Common;
30 using System.Resources;
35 /// Represents the method that handles the <see cref="Npgsql.NpgsqlDataAdapter.RowUpdated">RowUpdated</see> events.
37 /// <param name="sender">The source of the event.</param>
38 /// <param name="e">A <see cref="Npgsql.NpgsqlRowUpdatedEventArgs">NpgsqlRowUpdatedEventArgs</see> that contains the event data.</param>
39 public delegate void NpgsqlRowUpdatedEventHandler(Object sender, NpgsqlRowUpdatedEventArgs e);
42 /// Represents the method that handles the <see cref="Npgsql.NpgsqlDataAdapter.RowUpdating">RowUpdating</see> events.
44 /// <param name="sender">The source of the event.</param>
45 /// <param name="e">A <see cref="Npgsql.NpgsqlRowUpdatingEventArgs">NpgsqlRowUpdatingEventArgs</see> that contains the event data.</param>
46 public delegate void NpgsqlRowUpdatingEventHandler(Object sender, NpgsqlRowUpdatingEventArgs e);
49 public sealed class NpgsqlDataAdapter : DbDataAdapter, IDbDataAdapter
52 private NpgsqlCommand _selectCommand;
53 private NpgsqlCommand _updateCommand;
54 private NpgsqlCommand _deleteCommand;
55 private NpgsqlCommand _insertCommand;
58 private static readonly String CLASSNAME = "NpgsqlDataAdapter";
61 public event NpgsqlRowUpdatedEventHandler RowUpdated;
62 public event NpgsqlRowUpdatingEventHandler RowUpdating;
64 public NpgsqlDataAdapter()
67 public NpgsqlDataAdapter(NpgsqlCommand selectCommand)
69 NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, CLASSNAME);
70 _selectCommand = selectCommand;
73 public NpgsqlDataAdapter(String selectCommandText, NpgsqlConnection selectConnection) : this(new NpgsqlCommand(selectCommandText, selectConnection))
76 public NpgsqlDataAdapter(String selectCommandText, String selectConnectionString) : this(selectCommandText, new NpgsqlConnection(selectConnectionString))
80 protected override RowUpdatedEventArgs CreateRowUpdatedEvent(
83 StatementType statementType,
84 DataTableMapping tableMapping
87 NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "CreateRowUpdatedEvent");
88 return new NpgsqlRowUpdatedEventArgs(dataRow, command, statementType, tableMapping);
94 protected override RowUpdatingEventArgs CreateRowUpdatingEvent(
97 StatementType statementType,
98 DataTableMapping tableMapping
101 NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "CreateRowUpdatingEvent");
102 return new NpgsqlRowUpdatingEventArgs(dataRow, command, statementType, tableMapping);
105 protected override void OnRowUpdated(
106 RowUpdatedEventArgs value
109 NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "OnRowUpdated");
110 //base.OnRowUpdated(value);
111 if ((RowUpdated != null) && (value is NpgsqlRowUpdatedEventArgs))
112 RowUpdated(this, (NpgsqlRowUpdatedEventArgs) value);
116 protected override void OnRowUpdating(
117 RowUpdatingEventArgs value
120 NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "OnRowUpdating");
121 if ((RowUpdating != null) && (value is NpgsqlRowUpdatingEventArgs))
122 RowUpdating(this, (NpgsqlRowUpdatingEventArgs) value);
125 ITableMappingCollection IDataAdapter.TableMappings
129 return TableMappings;
133 IDbCommand IDbDataAdapter.DeleteCommand
137 NpgsqlEventLog.LogPropertyGet(LogLevel.Debug, CLASSNAME, "IDbDataAdapter.DeleteCommand");
138 return (NpgsqlCommand) DeleteCommand;
143 DeleteCommand = (NpgsqlCommand) value;
148 public NpgsqlCommand DeleteCommand
152 return _deleteCommand;
157 _deleteCommand = value;
161 IDbCommand IDbDataAdapter.SelectCommand
165 return (NpgsqlCommand) SelectCommand;
170 SelectCommand = (NpgsqlCommand) value;
175 public NpgsqlCommand SelectCommand
179 return _selectCommand;
184 _selectCommand = value;
188 IDbCommand IDbDataAdapter.UpdateCommand
192 NpgsqlEventLog.LogPropertyGet(LogLevel.Debug, CLASSNAME, "IDbDataAdapter.UpdateCommand");
193 return (NpgsqlCommand) UpdateCommand;
198 UpdateCommand = (NpgsqlCommand) value;
203 public NpgsqlCommand UpdateCommand
207 return _updateCommand;
212 _updateCommand = value;
216 IDbCommand IDbDataAdapter.InsertCommand
220 return (NpgsqlCommand) InsertCommand;
225 InsertCommand = (NpgsqlCommand) value;
230 public NpgsqlCommand InsertCommand
234 NpgsqlEventLog.LogPropertyGet(LogLevel.Debug, CLASSNAME, "InsertCommand");
235 return _insertCommand;
240 _insertCommand = value;
249 public class NpgsqlRowUpdatingEventArgs : RowUpdatingEventArgs
251 public NpgsqlRowUpdatingEventArgs (
254 StatementType statementType,
255 DataTableMapping tableMapping
256 ) : base(dataRow, command, statementType, tableMapping)
262 public class NpgsqlRowUpdatedEventArgs : RowUpdatedEventArgs
264 public NpgsqlRowUpdatedEventArgs (
267 StatementType statementType,
268 DataTableMapping tableMapping
269 ) : base(dataRow, command, statementType, tableMapping)