فهرست منبع

2002-05-24 Tim Coleman <[email protected]>
* System.Data.Common/DbDataAdapter.cs: remove IDbCommands, except
for get accessors. These should be implemented in derived classes. See
SqlDataAdapter for clues.
* System.Data.SqlClient/SqlDataAdapter.cs: implement IDbDataAdapter
* System.Data.Common/DataAdapter.cs:
* System.Data.Common/DataTableMappingCollection.cs:
* System.Data.Common/DataTableMapping.cs:
* System.Data.Common/DataColumnMappingCollection.cs:
* System.Data.Common/DataColumnMapping.cs:
Properly (I hope!) implement all of the appropriate interfaces
for these classes.

svn path=/trunk/mcs/; revision=4908

Tim Coleman 23 سال پیش
والد
کامیت
df2142c86f

+ 80 - 18
mcs/class/Mono.Data.PostgreSqlClient/Mono.Data.PostgreSqlClient/PgSqlDataAdapter.cs

@@ -22,8 +22,20 @@ namespace System.Data.SqlClient
 	/// to fill the DataSet and update a data source, all this 
 	/// from a SQL database.
 	/// </summary>
-	public sealed class SqlDataAdapter : DbDataAdapter 
+	public sealed class SqlDataAdapter : DbDataAdapter, IDbDataAdapter 
 	{
+		#region Fields
+	
+		SqlCommand deleteCommand;
+		SqlCommand insertCommand;
+		SqlCommand selectCommand;
+		SqlCommand updateCommand;
+
+		static readonly object EventRowUpdated = new object(); 
+		static readonly object EventRowUpdating = new object(); 
+
+		#endregion
+
 		#region Constructors
 		
 		public SqlDataAdapter () 	
@@ -31,12 +43,12 @@ namespace System.Data.SqlClient
 		{
 		}
 
-		public SqlDataAdapter (SqlCommand selectCommand) : base ()
+		public SqlDataAdapter (SqlCommand selectCommand) 
 		{
-			this.deleteCommand = new SqlCommand ();
-			this.insertCommand = new SqlCommand ();
-			this.selectCommand = selectCommand;
-			this.updateCommand = new SqlCommand ();
+			DeleteCommand = new SqlCommand ();
+			InsertCommand = new SqlCommand ();
+			SelectCommand = selectCommand;
+			UpdateCommand = new SqlCommand ();
 		}
 
 		public SqlDataAdapter (string selectCommandText, SqlConnection selectConnection) 
@@ -54,58 +66,108 @@ namespace System.Data.SqlClient
 		#region Properties
 
 		public new SqlCommand DeleteCommand {
-			get { return (SqlCommand)deleteCommand; }
+			get { return deleteCommand; }
 			set { deleteCommand = value; }
 		}
 
 		public new SqlCommand InsertCommand {
-			get { return (SqlCommand)insertCommand; }
+			get { return insertCommand; }
 			set { insertCommand = value; }
 		}
 
 		public new SqlCommand SelectCommand {
-			get { return (SqlCommand)selectCommand; }
+			get { return selectCommand; }
 			set { selectCommand = value; }
 		}
 
 		public new SqlCommand UpdateCommand {
-			get { return (SqlCommand)updateCommand; }
+			get { return updateCommand; }
 			set { updateCommand = value; }
 		}
 
+		IDbCommand IDbDataAdapter.DeleteCommand {
+			get { return DeleteCommand; }
+			set { 
+				if (!(value is SqlCommand)) 
+					throw new ArgumentException ();
+				DeleteCommand = (SqlCommand)value;
+			}
+		}
+
+		IDbCommand IDbDataAdapter.InsertCommand {
+			get { return InsertCommand; }
+			set { 
+				if (!(value is SqlCommand)) 
+					throw new ArgumentException ();
+				InsertCommand = (SqlCommand)value;
+			}
+		}
+
+		IDbCommand IDbDataAdapter.SelectCommand {
+			get { return SelectCommand; }
+			set { 
+				if (!(value is SqlCommand)) 
+					throw new ArgumentException ();
+				SelectCommand = (SqlCommand)value;
+			}
+		}
+
+		IDbCommand IDbDataAdapter.UpdateCommand {
+			get { return UpdateCommand; }
+			set { 
+				if (!(value is SqlCommand)) 
+					throw new ArgumentException ();
+				UpdateCommand = (SqlCommand)value;
+			}
+		}
+
+
+		ITableMappingCollection IDataAdapter.TableMappings {
+			get { return TableMappings; }
+		}
+
 		#endregion // Properties
 
 		#region Methods
 
-		[MonoTODO]
 		protected override RowUpdatedEventArgs CreateRowUpdatedEvent (DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) 
 		{
-			throw new NotImplementedException ();
+			return new SqlRowUpdatedEventArgs (dataRow, command, statementType, tableMapping);
 		}
 
 
-		[MonoTODO]
 		protected override RowUpdatingEventArgs CreateRowUpdatingEvent (DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) 
 		{
-			throw new NotImplementedException ();
+			return new SqlRowUpdatingEventArgs (dataRow, command, statementType, tableMapping);
 		}
 
 		protected override void OnRowUpdated (RowUpdatedEventArgs value) 
 		{
-			throw new NotImplementedException ();
+         		SqlRowUpdatedEventHandler handler = (SqlRowUpdatedEventHandler) Events[EventRowUpdated];
+			if ((handler != null) && (value is SqlRowUpdatedEventArgs))
+            			handler(this, (SqlRowUpdatedEventArgs) value);
 		}
 
 		protected override void OnRowUpdating (RowUpdatingEventArgs value) 
 		{
-			throw new NotImplementedException ();
+         		SqlRowUpdatingEventHandler handler = (SqlRowUpdatingEventHandler) Events[EventRowUpdating];
+			if ((handler != null) && (value is SqlRowUpdatingEventArgs))
+            			handler(this, (SqlRowUpdatingEventArgs) value);
 		}
 
 		#endregion // Methods
 
 		#region Events and Delegates
 
-		public event SqlRowUpdatedEventHandler RowUpdated;
-		public event SqlRowUpdatingEventHandler RowUpdating;
+		public event SqlRowUpdatedEventHandler RowUpdated {
+			add { Events.AddHandler (EventRowUpdated, value); }
+			remove { Events.RemoveHandler (EventRowUpdated, value); }
+		}
+
+		public event SqlRowUpdatingEventHandler RowUpdating {
+			add { Events.AddHandler (EventRowUpdating, value); }
+			remove { Events.RemoveHandler (EventRowUpdating, value); }
+		}
 
 		#endregion // Events and Delegates
 

+ 80 - 18
mcs/class/Mono.Data.PostgreSqlClient/PgSqlDataAdapter.cs

@@ -22,8 +22,20 @@ namespace System.Data.SqlClient
 	/// to fill the DataSet and update a data source, all this 
 	/// from a SQL database.
 	/// </summary>
-	public sealed class SqlDataAdapter : DbDataAdapter 
+	public sealed class SqlDataAdapter : DbDataAdapter, IDbDataAdapter 
 	{
+		#region Fields
+	
+		SqlCommand deleteCommand;
+		SqlCommand insertCommand;
+		SqlCommand selectCommand;
+		SqlCommand updateCommand;
+
+		static readonly object EventRowUpdated = new object(); 
+		static readonly object EventRowUpdating = new object(); 
+
+		#endregion
+
 		#region Constructors
 		
 		public SqlDataAdapter () 	
@@ -31,12 +43,12 @@ namespace System.Data.SqlClient
 		{
 		}
 
-		public SqlDataAdapter (SqlCommand selectCommand) : base ()
+		public SqlDataAdapter (SqlCommand selectCommand) 
 		{
-			this.deleteCommand = new SqlCommand ();
-			this.insertCommand = new SqlCommand ();
-			this.selectCommand = selectCommand;
-			this.updateCommand = new SqlCommand ();
+			DeleteCommand = new SqlCommand ();
+			InsertCommand = new SqlCommand ();
+			SelectCommand = selectCommand;
+			UpdateCommand = new SqlCommand ();
 		}
 
 		public SqlDataAdapter (string selectCommandText, SqlConnection selectConnection) 
@@ -54,58 +66,108 @@ namespace System.Data.SqlClient
 		#region Properties
 
 		public new SqlCommand DeleteCommand {
-			get { return (SqlCommand)deleteCommand; }
+			get { return deleteCommand; }
 			set { deleteCommand = value; }
 		}
 
 		public new SqlCommand InsertCommand {
-			get { return (SqlCommand)insertCommand; }
+			get { return insertCommand; }
 			set { insertCommand = value; }
 		}
 
 		public new SqlCommand SelectCommand {
-			get { return (SqlCommand)selectCommand; }
+			get { return selectCommand; }
 			set { selectCommand = value; }
 		}
 
 		public new SqlCommand UpdateCommand {
-			get { return (SqlCommand)updateCommand; }
+			get { return updateCommand; }
 			set { updateCommand = value; }
 		}
 
+		IDbCommand IDbDataAdapter.DeleteCommand {
+			get { return DeleteCommand; }
+			set { 
+				if (!(value is SqlCommand)) 
+					throw new ArgumentException ();
+				DeleteCommand = (SqlCommand)value;
+			}
+		}
+
+		IDbCommand IDbDataAdapter.InsertCommand {
+			get { return InsertCommand; }
+			set { 
+				if (!(value is SqlCommand)) 
+					throw new ArgumentException ();
+				InsertCommand = (SqlCommand)value;
+			}
+		}
+
+		IDbCommand IDbDataAdapter.SelectCommand {
+			get { return SelectCommand; }
+			set { 
+				if (!(value is SqlCommand)) 
+					throw new ArgumentException ();
+				SelectCommand = (SqlCommand)value;
+			}
+		}
+
+		IDbCommand IDbDataAdapter.UpdateCommand {
+			get { return UpdateCommand; }
+			set { 
+				if (!(value is SqlCommand)) 
+					throw new ArgumentException ();
+				UpdateCommand = (SqlCommand)value;
+			}
+		}
+
+
+		ITableMappingCollection IDataAdapter.TableMappings {
+			get { return TableMappings; }
+		}
+
 		#endregion // Properties
 
 		#region Methods
 
-		[MonoTODO]
 		protected override RowUpdatedEventArgs CreateRowUpdatedEvent (DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) 
 		{
-			throw new NotImplementedException ();
+			return new SqlRowUpdatedEventArgs (dataRow, command, statementType, tableMapping);
 		}
 
 
-		[MonoTODO]
 		protected override RowUpdatingEventArgs CreateRowUpdatingEvent (DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) 
 		{
-			throw new NotImplementedException ();
+			return new SqlRowUpdatingEventArgs (dataRow, command, statementType, tableMapping);
 		}
 
 		protected override void OnRowUpdated (RowUpdatedEventArgs value) 
 		{
-			throw new NotImplementedException ();
+         		SqlRowUpdatedEventHandler handler = (SqlRowUpdatedEventHandler) Events[EventRowUpdated];
+			if ((handler != null) && (value is SqlRowUpdatedEventArgs))
+            			handler(this, (SqlRowUpdatedEventArgs) value);
 		}
 
 		protected override void OnRowUpdating (RowUpdatingEventArgs value) 
 		{
-			throw new NotImplementedException ();
+         		SqlRowUpdatingEventHandler handler = (SqlRowUpdatingEventHandler) Events[EventRowUpdating];
+			if ((handler != null) && (value is SqlRowUpdatingEventArgs))
+            			handler(this, (SqlRowUpdatingEventArgs) value);
 		}
 
 		#endregion // Methods
 
 		#region Events and Delegates
 
-		public event SqlRowUpdatedEventHandler RowUpdated;
-		public event SqlRowUpdatingEventHandler RowUpdating;
+		public event SqlRowUpdatedEventHandler RowUpdated {
+			add { Events.AddHandler (EventRowUpdated, value); }
+			remove { Events.RemoveHandler (EventRowUpdated, value); }
+		}
+
+		public event SqlRowUpdatingEventHandler RowUpdating {
+			add { Events.AddHandler (EventRowUpdating, value); }
+			remove { Events.RemoveHandler (EventRowUpdating, value); }
+		}
 
 		#endregion // Events and Delegates
 

+ 14 - 0
mcs/class/System.Data/ChangeLog

@@ -1,3 +1,17 @@
+2002-05-24  Tim Coleman <[email protected]>
+	* System.Data.Common/DbDataAdapter.cs: remove IDbCommands, except
+	for get accessors.  These should be implemented in derived classes.  See
+	SqlDataAdapter for clues.
+	* System.Data.SqlClient/SqlDataAdapter.cs: implement IDbDataAdapter
+	* System.Data.Common/DataAdapter.cs:
+	* System.Data.Common/DataTableMappingCollection.cs:
+	* System.Data.Common/DataTableMapping.cs:
+	* System.Data.Common/DataColumnMappingCollection.cs:
+	* System.Data.Common/DataColumnMapping.cs:
+	Properly (I hope!) implement all of the appropriate interfaces
+	for these classes.  
+
+
 2002-05-23  Tim Coleman <[email protected]>
 	* System.Data.SqlClient/SqlCommand.cs: include
 	the BaseColumnName in the schema table.  Was missed before.

+ 5 - 1
mcs/class/System.Data/System.Data.Common/DataAdapter.cs

@@ -17,7 +17,7 @@ namespace System.Data.Common
 	/// <summary>
 	/// Represents a set of data commands and a database connection that are used to fill the DataSet and update the data source.
 	/// </summary>
-	public abstract class DataAdapter : Component
+	public abstract class DataAdapter : Component, IDataAdapter
 	{
 		#region Fields
 
@@ -68,6 +68,10 @@ namespace System.Data.Common
 			get { return tableMappings; }
 		}
 
+		ITableMappingCollection IDataAdapter.TableMappings {
+			get { return TableMappings; }
+		}
+
 		#endregion
 
 		#region Methods

+ 7 - 1
mcs/class/System.Data/System.Data.Common/DataColumnMapping.cs

@@ -14,7 +14,7 @@ namespace System.Data.Common
 	/// <summary>
 	/// Contains a generic column mapping for an object that inherits from DataAdapter. This class cannot be inherited.
 	/// </summary>
-	public sealed class DataColumnMapping : MarshalByRefObject //, IColumnMapping, ICloneable
+	public sealed class DataColumnMapping : MarshalByRefObject, IColumnMapping, ICloneable
 	{
 		private string srcColumn;
 		private string dsColumn;
@@ -46,6 +46,12 @@ namespace System.Data.Common
 			}
 		}
 
+		[MonoTODO]
+		object ICloneable.Clone ()
+		{
+			throw new NotImplementedException ();
+		}
+
 		public string SourceColumn {
 			get {
 				return this.srcColumn;

+ 38 - 7
mcs/class/System.Data/System.Data.Common/DataColumnMappingCollection.cs

@@ -3,10 +3,8 @@
 //
 // Author:
 //   Rodrigo Moya ([email protected])
-//   Tim Coleman ([email protected])
 //
 // (C) Ximian, Inc
-// (C) Copyright 2002 Tim Coleman
 //
 
 using System;
@@ -18,7 +16,7 @@ namespace System.Data.Common
 	/// <summary>
 	/// Contains a collection of DataColumnMapping objects. This class cannot be inherited.
 	/// </summary>
-	public sealed class DataColumnMappingCollection : MarshalByRefObject // , IColumnMappingCollection , IList, ICollection, IEnumerable
+	public sealed class DataColumnMappingCollection : MarshalByRefObject, IColumnMappingCollection , IList, ICollection, IEnumerable
 	{
 		#region Fields
 
@@ -60,6 +58,41 @@ namespace System.Data.Common
 			set { this[list.IndexOf (sourceColumns[sourceColumn])] = value; }
 		}
 
+                object ICollection.SyncRoot {
+                        get { return list.SyncRoot; }
+                }
+
+                bool ICollection.IsSynchronized {
+                        get { return list.IsSynchronized; }
+                }
+
+		object IColumnMappingCollection.this[string sourceColumn] {
+			get { return this[sourceColumn]; }
+			set {
+				if (!(value is DataColumnMapping))
+					throw new ArgumentException ();
+				this[sourceColumn] = (DataColumnMapping)value;
+			}
+		}
+
+                object IList.this[int index] {
+                        get { return this[index]; }
+                        set {
+                                if (!(value is DataColumnMapping))
+                                        throw new ArgumentException ();
+                                this[index] = (DataColumnMapping)value;
+                         }
+                }
+
+                bool IList.IsReadOnly {
+                        get { return false; }
+                }
+
+                bool IList.IsFixedSize {
+                        get { return false; }
+                }
+		
+
 		#endregion
 
 		#region Methods
@@ -132,17 +165,15 @@ namespace System.Data.Common
 			return list.GetEnumerator ();
 		}
 
-/* FIXME
 		IColumnMapping IColumnMappingCollection.Add (string sourceColumnName, string dataSetColumnName)
 		{
-			return (IColumnMapping)(Add (sourceColumnName, dataSetColumnName));
+			return Add (sourceColumnName, dataSetColumnName);
 		}
 
 		IColumnMapping IColumnMappingCollection.GetByDataSetColumn (string dataSetColumnName)
 		{
-			return (IColumnMapping)(GetByDataSetColumn (dataSetColumnName));
+			return GetByDataSetColumn (dataSetColumnName);
 		}
-*/
 
 		public int IndexOf (object value) 
 		{

+ 11 - 3
mcs/class/System.Data/System.Data.Common/DataTableMapping.cs

@@ -3,10 +3,8 @@
 //
 // Author:
 //   Rodrigo Moya ([email protected])
-//   Tim Coleman ([email protected])
 //
 // (C) Ximian, Inc
-// (C) Copyright 2002 Tim Coleman
 //
 
 using System.Data;
@@ -16,7 +14,7 @@ namespace System.Data.Common
 	/// <summary>
 	/// Contains a description of a mapped relationship between a source table and a DataTable. This class is used by a DataAdapter when populating a DataSet.
 	/// </summary>
-	public sealed class DataTableMapping : MarshalByRefObject // , ITableMapping, ICloneable
+	public sealed class DataTableMapping : MarshalByRefObject, ITableMapping, ICloneable
 	{
 		#region Fields
 
@@ -65,6 +63,10 @@ namespace System.Data.Common
 			get { return sourceTable; }
 			set { sourceTable = value; }
 		}
+
+		IColumnMappingCollection ITableMapping.ColumnMappings {
+			get { return ColumnMappings; }
+		}
 	
 		#endregion
 
@@ -81,6 +83,12 @@ namespace System.Data.Common
 			throw new NotImplementedException ();
 		}
 
+		[MonoTODO]
+		object ICloneable.Clone ()
+		{
+			throw new NotImplementedException ();
+		}
+
 		public override string ToString ()
 		{
 			return SourceTable; 

+ 48 - 4
mcs/class/System.Data/System.Data.Common/DataTableMappingCollection.cs

@@ -17,11 +17,8 @@ namespace System.Data.Common
 	/// <summary>
 	/// A collection of DataTableMapping objects. This class cannot be inherited.
 	/// </summary>
-	public sealed class DataTableMappingCollection :
-	MarshalByRefObject, // ITableMappingCollection, IList,
-	        IEnumerable //ICollection, 
+	public sealed class DataTableMappingCollection : MarshalByRefObject, ITableMappingCollection, IList, ICollection, IEnumerable
 	{
-
 		#region Fields
 
 		ArrayList mappings;
@@ -64,6 +61,41 @@ namespace System.Data.Common
 			set { this[mappings.IndexOf(sourceTables[sourceTable])] = value; }
 		}
 
+	
+		object IList.this[int index] {
+			get { return (object)(this[index]); }
+			set { 
+				if (!(value is DataTableMapping))
+					throw new ArgumentException (); 
+				this[index] = (DataTableMapping)value;
+			 } 
+		}
+
+		bool IList.IsReadOnly {
+			get { return false; }
+		}
+
+		bool IList.IsFixedSize {
+			get { return false; }
+		}
+
+		object ICollection.SyncRoot {
+			get { return mappings.SyncRoot; }
+		}
+
+		bool ICollection.IsSynchronized {
+			get { return mappings.IsSynchronized; }
+		}
+
+		object ITableMappingCollection.this[string sourceTable] {
+			get { return this[sourceTable]; }
+			set { 
+				if (!(value is DataTableMapping))
+					throw new ArgumentException ();
+				this[sourceTable] = (DataTableMapping)(value);
+			}
+		}
+
 		#endregion
 
 		#region Methods
@@ -156,6 +188,18 @@ namespace System.Data.Common
 			throw new NotImplementedException ();
 		}
 
+		[MonoTODO]
+		ITableMapping ITableMappingCollection.Add (string sourceTableName, string dataSetTableName)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		ITableMapping ITableMappingCollection.GetByDataSetTable (string dataSetTableName)
+		{
+			throw new NotImplementedException ();
+		}
+
 		[MonoTODO]
 		public void Remove (object value) 
 		{

+ 30 - 27
mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs

@@ -23,13 +23,8 @@ namespace System.Data.Common
 
 		public const string DefaultSourceTableName = "Table";
 
-		protected IDbCommand selectCommand;
-		protected IDbCommand insertCommand;
-		protected IDbCommand deleteCommand;
-		protected IDbCommand updateCommand;
-
 		#endregion
-
+		
 		#region Constructors
 
 		protected DbDataAdapter() 
@@ -40,30 +35,36 @@ namespace System.Data.Common
 
 		#region Properties
 
-		public IDbCommand SelectCommand {
-			get { return selectCommand; }
-			set { selectCommand = value; }
+		IDbCommand DeleteCommand {
+			get { return ((IDbDataAdapter)this).DeleteCommand; }
 		}
 
-		public IDbCommand InsertCommand {
-			get { return insertCommand; }
-			set { insertCommand = value; }
+		IDbCommand InsertCommand {
+			get { return ((IDbDataAdapter)this).InsertCommand; }
 		}
 
-		public IDbCommand DeleteCommand {
-			get { return deleteCommand; }
-			set { deleteCommand = value; }
+		IDbCommand SelectCommand {
+			get { return ((IDbDataAdapter)this).SelectCommand; }
 		}
 
-		public IDbCommand UpdateCommand {
-			get { return updateCommand; }
-			set { updateCommand = value; }
+
+		IDbCommand UpdateCommand {
+			get { return ((IDbDataAdapter)this).UpdateCommand; }
 		}
 
 		#endregion
 
 		#region Methods
 
+		protected abstract RowUpdatedEventArgs CreateRowUpdatedEvent (DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping);
+		protected abstract RowUpdatingEventArgs CreateRowUpdatingEvent (DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping);
+
+		[MonoTODO]
+		protected override void Dispose (bool disposing)
+		{
+			throw new NotImplementedException ();
+		}
+
                 public override int Fill (DataSet dataSet)
                 {
 			return Fill (dataSet, DefaultSourceTableName);
@@ -91,7 +92,7 @@ namespace System.Data.Common
 
 		public int Fill (DataSet dataSet, int startRecord, int maxRecords, string srcTable) 
 		{
-			return this.Fill (dataSet, startRecord, maxRecords, srcTable, selectCommand, CommandBehavior.Default);
+			return this.Fill (dataSet, startRecord, maxRecords, srcTable, SelectCommand, CommandBehavior.Default);
 		}
 
 		protected virtual int Fill (DataSet dataSet, string srcTable, IDataReader dataReader, int startRecord, int maxRecords) 
@@ -250,6 +251,12 @@ namespace System.Data.Common
 			throw new NotImplementedException ();
 		}
 
+		[MonoTODO]
+		object ICloneable.Clone ()
+		{
+			throw new NotImplementedException ();
+		}
+
 		[MonoTODO]
 		public int Update (DataRow[] dataRows) 
 		{
@@ -280,9 +287,7 @@ namespace System.Data.Common
 			throw new NotImplementedException ();
 		}
 
-		protected abstract RowUpdatedEventArgs CreateRowUpdatedEvent (DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping);
 
-		protected abstract RowUpdatingEventArgs CreateRowUpdatingEvent (DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping);
 
 		[MonoTODO]
 		protected virtual void OnFillError (FillErrorEventArgs value) 
@@ -293,13 +298,11 @@ namespace System.Data.Common
 		protected abstract void OnRowUpdated (RowUpdatedEventArgs value);
 		protected abstract void OnRowUpdating (RowUpdatingEventArgs value);
 		
-		public event FillErrorEventHandler FillError;
+		#endregion
+		
+		#region Events
 
-		[MonoTODO]
-		public object Clone ()
-		{
-			throw new NotImplementedException ();
-		}
+		public event FillErrorEventHandler FillError;
 
 		#endregion
 	}

+ 80 - 18
mcs/class/System.Data/System.Data.SqlClient/SqlDataAdapter.cs

@@ -22,8 +22,20 @@ namespace System.Data.SqlClient
 	/// to fill the DataSet and update a data source, all this 
 	/// from a SQL database.
 	/// </summary>
-	public sealed class SqlDataAdapter : DbDataAdapter 
+	public sealed class SqlDataAdapter : DbDataAdapter, IDbDataAdapter 
 	{
+		#region Fields
+	
+		SqlCommand deleteCommand;
+		SqlCommand insertCommand;
+		SqlCommand selectCommand;
+		SqlCommand updateCommand;
+
+		static readonly object EventRowUpdated = new object(); 
+		static readonly object EventRowUpdating = new object(); 
+
+		#endregion
+
 		#region Constructors
 		
 		public SqlDataAdapter () 	
@@ -31,12 +43,12 @@ namespace System.Data.SqlClient
 		{
 		}
 
-		public SqlDataAdapter (SqlCommand selectCommand) : base ()
+		public SqlDataAdapter (SqlCommand selectCommand) 
 		{
-			this.deleteCommand = new SqlCommand ();
-			this.insertCommand = new SqlCommand ();
-			this.selectCommand = selectCommand;
-			this.updateCommand = new SqlCommand ();
+			DeleteCommand = new SqlCommand ();
+			InsertCommand = new SqlCommand ();
+			SelectCommand = selectCommand;
+			UpdateCommand = new SqlCommand ();
 		}
 
 		public SqlDataAdapter (string selectCommandText, SqlConnection selectConnection) 
@@ -54,58 +66,108 @@ namespace System.Data.SqlClient
 		#region Properties
 
 		public new SqlCommand DeleteCommand {
-			get { return (SqlCommand)deleteCommand; }
+			get { return deleteCommand; }
 			set { deleteCommand = value; }
 		}
 
 		public new SqlCommand InsertCommand {
-			get { return (SqlCommand)insertCommand; }
+			get { return insertCommand; }
 			set { insertCommand = value; }
 		}
 
 		public new SqlCommand SelectCommand {
-			get { return (SqlCommand)selectCommand; }
+			get { return selectCommand; }
 			set { selectCommand = value; }
 		}
 
 		public new SqlCommand UpdateCommand {
-			get { return (SqlCommand)updateCommand; }
+			get { return updateCommand; }
 			set { updateCommand = value; }
 		}
 
+		IDbCommand IDbDataAdapter.DeleteCommand {
+			get { return DeleteCommand; }
+			set { 
+				if (!(value is SqlCommand)) 
+					throw new ArgumentException ();
+				DeleteCommand = (SqlCommand)value;
+			}
+		}
+
+		IDbCommand IDbDataAdapter.InsertCommand {
+			get { return InsertCommand; }
+			set { 
+				if (!(value is SqlCommand)) 
+					throw new ArgumentException ();
+				InsertCommand = (SqlCommand)value;
+			}
+		}
+
+		IDbCommand IDbDataAdapter.SelectCommand {
+			get { return SelectCommand; }
+			set { 
+				if (!(value is SqlCommand)) 
+					throw new ArgumentException ();
+				SelectCommand = (SqlCommand)value;
+			}
+		}
+
+		IDbCommand IDbDataAdapter.UpdateCommand {
+			get { return UpdateCommand; }
+			set { 
+				if (!(value is SqlCommand)) 
+					throw new ArgumentException ();
+				UpdateCommand = (SqlCommand)value;
+			}
+		}
+
+
+		ITableMappingCollection IDataAdapter.TableMappings {
+			get { return TableMappings; }
+		}
+
 		#endregion // Properties
 
 		#region Methods
 
-		[MonoTODO]
 		protected override RowUpdatedEventArgs CreateRowUpdatedEvent (DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) 
 		{
-			throw new NotImplementedException ();
+			return new SqlRowUpdatedEventArgs (dataRow, command, statementType, tableMapping);
 		}
 
 
-		[MonoTODO]
 		protected override RowUpdatingEventArgs CreateRowUpdatingEvent (DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) 
 		{
-			throw new NotImplementedException ();
+			return new SqlRowUpdatingEventArgs (dataRow, command, statementType, tableMapping);
 		}
 
 		protected override void OnRowUpdated (RowUpdatedEventArgs value) 
 		{
-			throw new NotImplementedException ();
+         		SqlRowUpdatedEventHandler handler = (SqlRowUpdatedEventHandler) Events[EventRowUpdated];
+			if ((handler != null) && (value is SqlRowUpdatedEventArgs))
+            			handler(this, (SqlRowUpdatedEventArgs) value);
 		}
 
 		protected override void OnRowUpdating (RowUpdatingEventArgs value) 
 		{
-			throw new NotImplementedException ();
+         		SqlRowUpdatingEventHandler handler = (SqlRowUpdatingEventHandler) Events[EventRowUpdating];
+			if ((handler != null) && (value is SqlRowUpdatingEventArgs))
+            			handler(this, (SqlRowUpdatingEventArgs) value);
 		}
 
 		#endregion // Methods
 
 		#region Events and Delegates
 
-		public event SqlRowUpdatedEventHandler RowUpdated;
-		public event SqlRowUpdatingEventHandler RowUpdating;
+		public event SqlRowUpdatedEventHandler RowUpdated {
+			add { Events.AddHandler (EventRowUpdated, value); }
+			remove { Events.RemoveHandler (EventRowUpdated, value); }
+		}
+
+		public event SqlRowUpdatingEventHandler RowUpdating {
+			add { Events.AddHandler (EventRowUpdating, value); }
+			remove { Events.RemoveHandler (EventRowUpdating, value); }
+		}
 
 		#endregion // Events and Delegates