wasCSharpSQLite – Blame information for rev
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | // |
2 | // Community.CsharpSqlite.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 |
||
10 | // |
||
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. |
||
29 | // |
||
30 | |||
31 | using System; |
||
32 | using System.Data; |
||
33 | using System.Data.Common; |
||
34 | using System.Collections; |
||
35 | using System.Text; |
||
36 | |||
37 | namespace Community.CsharpSqlite.SQLiteClient |
||
38 | { |
||
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 |
||
44 | { |
||
45 | #region Public Events |
||
46 | |||
47 | /// <summary> |
||
48 | /// Occurs during <see cref="DbDataAdapter.Update">Update</see> after a |
||
49 | /// command is executed against the data source. The attempt to update |
||
50 | /// is made, so the event fires. |
||
51 | /// </summary> |
||
52 | public event SqliteRowUpdatedEventHandler RowUpdated; |
||
53 | |||
54 | /// <summary> |
||
55 | /// Occurs during <see cref="DbDataAdapter.Update">Update</see> before a |
||
56 | /// command is executed against the data source. The attempt to update |
||
57 | /// is made, so the event fires. |
||
58 | /// </summary> |
||
59 | public event SqliteRowUpdatingEventHandler RowUpdating; |
||
60 | |||
61 | #endregion |
||
62 | |||
63 | #region Contructors |
||
64 | |||
65 | /// <summary> |
||
66 | /// Initializes a new instance of the <see cref="SqliteDataAdapter">SqliteDataAdapter</see> class. |
||
67 | /// </summary> |
||
68 | public SqliteDataAdapter() |
||
69 | { |
||
70 | } |
||
71 | |||
72 | /// <summary> |
||
73 | /// Initializes a new instance of the <see cref="SqliteDataAdapter">SqliteDataAdapter</see> class |
||
74 | /// with the specified SqliteCommand as the SelectCommand property. |
||
75 | /// </summary> |
||
76 | /// <param name="selectCommand"></param> |
||
77 | public SqliteDataAdapter(DbCommand selectCommand) |
||
78 | { |
||
79 | SelectCommand = selectCommand; |
||
80 | } |
||
81 | |||
82 | /// <summary> |
||
83 | /// Initializes a new instance of the <see cref="SqliteDataAdapter">SqliteDataAdapter</see> class |
||
84 | /// with a SelectCommand and a SqliteConnection object. |
||
85 | /// </summary> |
||
86 | /// <param name="selectCommandText"></param> |
||
87 | /// <param name="connection"></param> |
||
88 | public SqliteDataAdapter(string selectCommandText, SqliteConnection connection) |
||
89 | { |
||
90 | DbCommand cmd = connection.CreateCommand(); |
||
91 | cmd.CommandText = selectCommandText; |
||
92 | SelectCommand = cmd; |
||
93 | } |
||
94 | |||
95 | /// <summary> |
||
96 | /// Initializes a new instance of the <see cref="SqliteDataAdapter">SqliteDataAdapter</see> class |
||
97 | /// with a SelectCommand and a connection string. |
||
98 | /// </summary> |
||
99 | /// <param name="selectCommandText"></param> |
||
100 | /// <param name="connectionString"></param> |
||
101 | public SqliteDataAdapter(string selectCommandText, string connectionString) : this(selectCommandText ,new SqliteConnection(connectionString)) |
||
102 | { |
||
103 | } |
||
104 | |||
105 | #endregion |
||
106 | |||
107 | #region Protected Methods |
||
108 | |||
109 | /// <summary> |
||
110 | /// Initializes a new instance of the <see cref="RowUpdatedEventArgs">RowUpdatedEventArgs</see> class. |
||
111 | /// </summary> |
||
112 | /// <param name="dataRow">The DataRow used to update the data source.</param> |
||
113 | /// <param name="command">The IDbCommand executed during the Update.</param> |
||
114 | /// <param name="statementType">Whether the command is an UPDATE, INSERT, DELETE, or SELECT statement.</param> |
||
115 | /// <param name="tableMapping">A DataTableMapping object.</param> |
||
116 | /// <returns></returns> |
||
117 | protected override RowUpdatedEventArgs CreateRowUpdatedEvent(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) |
||
118 | { |
||
119 | return new SqliteRowUpdatedEventArgs (dataRow, command, statementType, tableMapping); |
||
120 | } |
||
121 | |||
122 | /// <summary> |
||
123 | /// |
||
124 | /// </summary> |
||
125 | /// <param name="dataRow">The DataRow used to update the data source.</param> |
||
126 | /// <param name="command">The IDbCommand executed during the Update.</param> |
||
127 | /// <param name="statementType">Whether the command is an UPDATE, INSERT, DELETE, or SELECT statement.</param> |
||
128 | /// <param name="tableMapping">A DataTableMapping object.</param> |
||
129 | /// <returns></returns> |
||
130 | protected override RowUpdatingEventArgs CreateRowUpdatingEvent(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) |
||
131 | { |
||
132 | return new SqliteRowUpdatingEventArgs(dataRow, command, statementType, tableMapping); |
||
133 | } |
||
134 | |||
135 | /// <summary> |
||
136 | /// Raises the RowUpdated event of a Sqlite data provider. |
||
137 | /// </summary> |
||
138 | /// <param name="args">A RowUpdatedEventArgs that contains the event data.</param> |
||
139 | protected override void OnRowUpdating (RowUpdatingEventArgs args) |
||
140 | { |
||
141 | if (RowUpdating != null) |
||
142 | RowUpdating(this, args); |
||
143 | } |
||
144 | |||
145 | /// <summary> |
||
146 | /// Raises the RowUpdating event of Sqlite data provider. |
||
147 | /// </summary> |
||
148 | /// <param name="args">An RowUpdatingEventArgs that contains the event data.</param> |
||
149 | protected override void OnRowUpdated (RowUpdatedEventArgs args) |
||
150 | { |
||
151 | if (RowUpdated != null) |
||
152 | RowUpdated(this, args); |
||
153 | } |
||
154 | |||
155 | #endregion |
||
156 | } |
||
157 | } |