(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / Mono.Data.SqliteClient / Mono.Data.SqliteClient / SqliteDataAdapter.cs
blob263779df45846c87166ca85e1220b54373abe906
1 //
2 // Mono.Data.SqliteClient.SqliteDataAdapter.cs
3 //
4 // Represents a set of data commands and a database connection that are used
5 // to fill the DataSet and update the data source.
6 //
7 // Author(s): Everaldo Canuto <everaldo_canuto@yahoo.com.br>
8 //
9 // Copyright (C) 2004 Everaldo Canuto
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 //
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 //
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using System;
32 using System.Data;
33 using System.Data.Common;
34 using System.Collections;
35 using System.Text;
37 namespace Mono.Data.SqliteClient
39 /// <summary>
40 /// Represents a set of data commands and a database connection that are used
41 /// to fill the <see cref="DataSet">DataSet</see> and update the data source.
42 /// </summary>
43 public class SqliteDataAdapter : DbDataAdapter, IDbDataAdapter
45 #region Fields
47 private IDbCommand _deleteCommand;
48 private IDbCommand _insertCommand;
49 private IDbCommand _selectCommand;
50 private IDbCommand _updateCommand;
52 #endregion
54 #region Public Events
56 /// <summary>
57 /// Occurs during <see cref="DbDataAdapter.Update">Update</see> after a
58 /// command is executed against the data source. The attempt to update
59 /// is made, so the event fires.
60 /// </summary>
61 public event SqliteRowUpdatedEventHandler RowUpdated;
63 /// <summary>
64 /// Occurs during <see cref="DbDataAdapter.Update">Update</see> before a
65 /// command is executed against the data source. The attempt to update
66 /// is made, so the event fires.
67 /// </summary>
68 public event SqliteRowUpdatingEventHandler RowUpdating;
70 #endregion
72 #region Contructors
74 /// <summary>
75 /// Initializes a new instance of the <see cref="SqliteDataAdapter">SqliteDataAdapter</see> class.
76 /// </summary>
77 public SqliteDataAdapter()
81 /// <summary>
82 /// Initializes a new instance of the <see cref="SqliteDataAdapter">SqliteDataAdapter</see> class
83 /// with the specified SqliteCommand as the SelectCommand property.
84 /// </summary>
85 /// <param name="selectCommand"></param>
86 public SqliteDataAdapter(IDbCommand selectCommand)
88 SelectCommand = selectCommand;
91 /// <summary>
92 /// Initializes a new instance of the <see cref="SqliteDataAdapter">SqliteDataAdapter</see> class
93 /// with a SelectCommand and a SqliteConnection object.
94 /// </summary>
95 /// <param name="selectCommandText"></param>
96 /// <param name="connection"></param>
97 public SqliteDataAdapter(string selectCommandText, SqliteConnection connection)
99 IDbCommand cmd = connection.CreateCommand();
100 cmd.CommandText = selectCommandText;
101 SelectCommand = cmd;
104 /// <summary>
105 /// Initializes a new instance of the <see cref="SqliteDataAdapter">SqliteDataAdapter</see> class
106 /// with a SelectCommand and a connection string.
107 /// </summary>
108 /// <param name="selectCommandText"></param>
109 /// <param name="connectionString"></param>
110 public SqliteDataAdapter(string selectCommandText, string connectionString) : this(selectCommandText ,new SqliteConnection(connectionString))
114 #endregion
116 #region Public Properties
118 /// <summary>
119 /// Gets or sets a Transact-SQL statement or stored procedure to delete
120 /// records from the data set.
121 /// </summary>
122 public IDbCommand DeleteCommand {
123 get { return _deleteCommand; }
124 set { _deleteCommand = value; }
127 /// <summary>
128 /// Gets or sets a Transact-SQL statement or stored procedure to insert
129 /// new records into the data source.
130 /// </summary>
131 public IDbCommand InsertCommand {
132 get { return _insertCommand; }
133 set { _insertCommand = value; }
136 /// <summary>
137 /// Gets or sets a Transact-SQL statement or stored procedure used to
138 /// select records in the data source.
139 /// </summary>
140 public IDbCommand SelectCommand {
141 get { return _selectCommand; }
142 set { _selectCommand = value; }
145 /// <summary>
146 /// Gets or sets a Transact-SQL statement or stored procedure used to
147 /// update records in the data source.
148 /// </summary>
149 public IDbCommand UpdateCommand {
150 get { return _updateCommand; }
151 set { _updateCommand = value; }
154 #endregion
156 #region Protected Methods
158 /// <summary>
159 /// Initializes a new instance of the <see cref="RowUpdatedEventArgs">RowUpdatedEventArgs</see> class.
160 /// </summary>
161 /// <param name="dataRow">The DataRow used to update the data source.</param>
162 /// <param name="command">The IDbCommand executed during the Update.</param>
163 /// <param name="statementType">Whether the command is an UPDATE, INSERT, DELETE, or SELECT statement.</param>
164 /// <param name="tableMapping">A DataTableMapping object.</param>
165 /// <returns></returns>
166 protected override RowUpdatedEventArgs CreateRowUpdatedEvent(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
168 return new SqliteRowUpdatedEventArgs (dataRow, command, statementType, tableMapping);
171 /// <summary>
172 ///
173 /// </summary>
174 /// <param name="dataRow">The DataRow used to update the data source.</param>
175 /// <param name="command">The IDbCommand executed during the Update.</param>
176 /// <param name="statementType">Whether the command is an UPDATE, INSERT, DELETE, or SELECT statement.</param>
177 /// <param name="tableMapping">A DataTableMapping object.</param>
178 /// <returns></returns>
179 protected override RowUpdatingEventArgs CreateRowUpdatingEvent(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
181 return new SqliteRowUpdatingEventArgs(dataRow, command, statementType, tableMapping);
184 /// <summary>
185 /// Raises the RowUpdated event of a Sqlite data provider.
186 /// </summary>
187 /// <param name="args">A RowUpdatedEventArgs that contains the event data.</param>
188 protected override void OnRowUpdating (RowUpdatingEventArgs args)
190 if (RowUpdating != null)
191 RowUpdating(this, args);
194 /// <summary>
195 /// Raises the RowUpdating event of Sqlite data provider.
196 /// </summary>
197 /// <param name="args">An RowUpdatingEventArgs that contains the event data.</param>
198 protected override void OnRowUpdated (RowUpdatedEventArgs args)
200 if (RowUpdated != null)
201 RowUpdated(this, args);
204 #endregion