2 // SqlSharpDataAdapter.cs - data adapter for SQL#
3 // but uses a data reader
4 // as the source of data
7 // System.Data.SqlSharpClient.SqlSharpDataAdapter.cs
8 // in Mono http://www.go-mono.com/
11 // Rodrigo Moya (rodrigo@ximian.com)
12 // Daniel Morgan (danielmorgan@verizon.net)
13 // Tim Coleman (tim@timcoleman.com)
15 // (C) Ximian, Inc 2002
16 // Copyright (C) 2002 Tim Coleman
17 // Copyright (C) 2002, 2003 Daniel Morgan
21 using System.ComponentModel;
23 using System.Data.Common;
25 namespace Mono.Data.SqlSharp
27 [DefaultEvent ("RowUpdated")]
28 public sealed class SqlSharpDataAdapter : DbDataAdapter, IDbDataAdapter
32 bool disposed = false;
33 IDbCommand deleteCommand;
34 IDbCommand insertCommand;
35 IDbCommand selectCommand;
36 IDbCommand updateCommand;
42 public SqlSharpDataAdapter ()
46 public SqlSharpDataAdapter (IDbCommand selectCommand)
50 SelectCommand = selectCommand;
58 // [DataCategory ("Update")]
59 [DataSysDescription ("Used during Update for deleted rows in DataSet.")]
61 public IDbCommand DeleteCommand {
62 get { return deleteCommand; }
63 set { deleteCommand = value; }
66 // [DataCategory ("Update")]
67 [DataSysDescription ("Used during Update for new rows in DataSet.")]
69 public IDbCommand InsertCommand {
70 get { return insertCommand; }
71 set { insertCommand = value; }
74 // [DataCategory ("Fill")]
75 [DataSysDescription ("Used during Fill/FillSchema.")]
77 public IDbCommand SelectCommand {
78 get { return selectCommand; }
79 set { selectCommand = value; }
82 // [DataCategory ("Update")]
83 [DataSysDescription ("Used during Update for modified rows in DataSet.")]
85 public IDbCommand UpdateCommand {
86 get { return updateCommand; }
87 set { updateCommand = value; }
90 IDbCommand IDbDataAdapter.DeleteCommand {
91 get { return DeleteCommand; }
93 DeleteCommand = value;
97 IDbCommand IDbDataAdapter.InsertCommand {
98 get { return InsertCommand; }
100 InsertCommand = value;
104 IDbCommand IDbDataAdapter.SelectCommand {
105 get { return SelectCommand; }
107 SelectCommand = value;
111 IDbCommand IDbDataAdapter.UpdateCommand {
112 get { return UpdateCommand; }
114 UpdateCommand = value;
119 ITableMappingCollection IDataAdapter.TableMappings {
120 get { return TableMappings; }
123 #endregion // Properties
127 protected override RowUpdatedEventArgs CreateRowUpdatedEvent (DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
129 return new SqlSharpRowUpdatedEventArgs (dataRow, command, statementType, tableMapping);
133 protected override RowUpdatingEventArgs CreateRowUpdatingEvent (DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
135 return new SqlSharpRowUpdatingEventArgs (dataRow, command, statementType, tableMapping);
138 protected override void Dispose (bool disposing)
142 // Release managed resources
144 // Release unmanaged resources
149 protected override void OnRowUpdated (RowUpdatedEventArgs value)
151 if (RowUpdated != null)
152 RowUpdated (this, (SqlSharpRowUpdatedEventArgs) value);
155 protected override void OnRowUpdating (RowUpdatingEventArgs value)
157 if (RowUpdating != null)
158 RowUpdating (this, (SqlSharpRowUpdatingEventArgs) value);
161 public int FillTable (DataTable dataTable, IDataReader dataReader)
163 return base.Fill (dataTable, dataReader);
166 #endregion // Methods
168 #region Events and Delegates
170 // [DataCategory ("Update")]
171 [DataSysDescription ("Event triggered before every DataRow during Update.")]
172 public event SqlSharpRowUpdatedEventHandler RowUpdated;
174 // [DataCategory ("Update")]
175 [DataSysDescription ("Event triggered after every DataRow during Update.")]
176 public event SqlSharpRowUpdatingEventHandler RowUpdating;
178 #endregion // Events and Delegates
181 public sealed class SqlSharpRowUpdatedEventArgs : RowUpdatedEventArgs {
184 public SqlSharpRowUpdatedEventArgs (DataRow row, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
185 : base (row, command, statementType, tableMapping) {
188 #endregion // Constructors
192 public new IDbCommand Command {
193 get { return base.Command; }
196 #endregion // Properties
199 public delegate void SqlSharpRowUpdatedEventHandler (object sender, SqlSharpRowUpdatedEventArgs e);
201 public sealed class SqlSharpRowUpdatingEventArgs : RowUpdatingEventArgs {
204 public SqlSharpRowUpdatingEventArgs (DataRow row, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
205 : base (row, command, statementType, tableMapping) {
208 #endregion // Constructors
212 public new IDbCommand Command {
213 get { return base.Command; }
214 set { base.Command = value; }
217 #endregion // Properties
220 public delegate void SqlSharpRowUpdatingEventHandler(object sender, SqlSharpRowUpdatingEventArgs e);