// // Community.CsharpSqlite.SQLiteClient.SqliteDataAdapter.cs // // Represents a set of data commands and a database connection that are used // to fill the DataSet and update the data source. // // Author(s): Everaldo Canuto // // Copyright (C) 2004 Everaldo Canuto // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // using System; using System.Data; using System.Data.Common; using System.Collections; using System.Text; namespace Community.CsharpSqlite.SQLiteClient { /// /// Represents a set of data commands and a database connection that are used /// to fill the DataSet and update the data source. /// public class SqliteDataAdapter : DbDataAdapter { #region Public Events /// /// Occurs during Update after a /// command is executed against the data source. The attempt to update /// is made, so the event fires. /// public event SqliteRowUpdatedEventHandler RowUpdated; /// /// Occurs during Update before a /// command is executed against the data source. The attempt to update /// is made, so the event fires. /// public event SqliteRowUpdatingEventHandler RowUpdating; #endregion #region Contructors /// /// Initializes a new instance of the SqliteDataAdapter class. /// public SqliteDataAdapter() { } /// /// Initializes a new instance of the SqliteDataAdapter class /// with the specified SqliteCommand as the SelectCommand property. /// /// public SqliteDataAdapter(DbCommand selectCommand) { SelectCommand = selectCommand; } /// /// Initializes a new instance of the SqliteDataAdapter class /// with a SelectCommand and a SqliteConnection object. /// /// /// public SqliteDataAdapter(string selectCommandText, SqliteConnection connection) { DbCommand cmd = connection.CreateCommand(); cmd.CommandText = selectCommandText; SelectCommand = cmd; } /// /// Initializes a new instance of the SqliteDataAdapter class /// with a SelectCommand and a connection string. /// /// /// public SqliteDataAdapter(string selectCommandText, string connectionString) : this(selectCommandText ,new SqliteConnection(connectionString)) { } #endregion #region Protected Methods /// /// Initializes a new instance of the RowUpdatedEventArgs class. /// /// The DataRow used to update the data source. /// The IDbCommand executed during the Update. /// Whether the command is an UPDATE, INSERT, DELETE, or SELECT statement. /// A DataTableMapping object. /// protected override RowUpdatedEventArgs CreateRowUpdatedEvent(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) { return new SqliteRowUpdatedEventArgs (dataRow, command, statementType, tableMapping); } /// /// /// /// The DataRow used to update the data source. /// The IDbCommand executed during the Update. /// Whether the command is an UPDATE, INSERT, DELETE, or SELECT statement. /// A DataTableMapping object. /// protected override RowUpdatingEventArgs CreateRowUpdatingEvent(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) { return new SqliteRowUpdatingEventArgs(dataRow, command, statementType, tableMapping); } /// /// Raises the RowUpdated event of a Sqlite data provider. /// /// A RowUpdatedEventArgs that contains the event data. protected override void OnRowUpdating (RowUpdatingEventArgs args) { if (RowUpdating != null) RowUpdating(this, args); } /// /// Raises the RowUpdating event of Sqlite data provider. /// /// An RowUpdatingEventArgs that contains the event data. protected override void OnRowUpdated (RowUpdatedEventArgs args) { if (RowUpdated != null) RowUpdated(this, args); } #endregion } }