X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FSystem.Data%2FSystem.Data.Common%2FDbDataAdapter.cs;h=918da04f502013c941a25eccf00e34355621c468;hb=aef0b3e04cdb066aa84ecb9ac1770c0aa936d150;hp=3fdc3ca11052a0f53df4ee8ba5d95bd44fef5082;hpb=0717f141b92db56481cc09af70c026d7ffad8921;p=mono.git diff --git a/mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs b/mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs index 3fdc3ca1105..918da04f502 100644 --- a/mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs +++ b/mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs @@ -43,11 +43,7 @@ using System.Runtime.InteropServices; namespace System.Data.Common { -#if NET_2_0 public abstract class DbDataAdapter : DataAdapter, IDbDataAdapter, IDataAdapter, ICloneable -#else - public abstract class DbDataAdapter : DataAdapter, ICloneable -#endif { #region Fields @@ -55,12 +51,10 @@ namespace System.Data.Common const string DefaultSourceColumnName = "Column"; CommandBehavior _behavior = CommandBehavior.Default; -#if NET_2_0 IDbCommand _selectCommand; IDbCommand _updateCommand; IDbCommand _deleteCommand; IDbCommand _insertCommand; -#endif #endregion // Fields @@ -78,7 +72,6 @@ namespace System.Data.Common #region Properties -#if NET_2_0 protected internal CommandBehavior FillCommandBehavior { get { return _behavior; } set { _behavior = value; } @@ -172,23 +165,11 @@ namespace System.Data.Common throw new NotSupportedException (); } } -#endif #endregion // Properties - #region Events - -#if ONLY_1_0 || ONLY_1_1 - [DataCategory ("Fill")] - [DataSysDescription ("Event triggered when a recoverable error occurs during Fill.")] - public event FillErrorEventHandler FillError; - -#endif - #endregion // Events - #region Methods -#if NET_2_0 protected virtual RowUpdatedEventArgs CreateRowUpdatedEvent (DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) @@ -224,18 +205,6 @@ namespace System.Data.Common } } } -#else - protected abstract RowUpdatedEventArgs CreateRowUpdatedEvent (DataRow dataRow, IDbCommand command, - StatementType statementType, - DataTableMapping tableMapping); - - protected abstract RowUpdatingEventArgs CreateRowUpdatingEvent (DataRow dataRow, IDbCommand command, - StatementType statementType, - DataTableMapping tableMapping); - - protected abstract void OnRowUpdated (RowUpdatedEventArgs value); - protected abstract void OnRowUpdating (RowUpdatingEventArgs value); -#endif protected override void Dispose (bool disposing) { @@ -278,12 +247,6 @@ namespace System.Data.Common return Fill (dataSet, 0, 0, srcTable, ((IDbDataAdapter) this).SelectCommand, _behavior); } -#if !NET_2_0 - protected virtual int Fill (DataTable dataTable, IDataReader dataReader) - { - return base.FillInternal (dataTable, dataReader); - } -#endif protected virtual int Fill (DataTable dataTable, IDbCommand command, CommandBehavior behavior) { @@ -302,7 +265,6 @@ namespace System.Data.Common return this.Fill (dataSet, startRecord, maxRecords, srcTable, ((IDbDataAdapter) this).SelectCommand, _behavior); } -#if NET_2_0 [MonoTODO] public int Fill (int startRecord, int maxRecords, params DataTable[] dataTables) { @@ -314,12 +276,6 @@ namespace System.Data.Common { throw new NotImplementedException (); } -#else - protected virtual int Fill (DataSet dataSet, string srcTable, IDataReader dataReader, int startRecord, int maxRecords) - { - return base.FillInternal (dataSet, srcTable, dataReader, startRecord, maxRecords); - } -#endif protected virtual int Fill (DataSet dataSet, int startRecord, int maxRecords, string srcTable, IDbCommand command, CommandBehavior behavior) { @@ -338,7 +294,6 @@ namespace System.Data.Common startRecord, maxRecords); } -#if NET_2_0 /// /// Fills the given datatable using values from reader. if a value /// for a column is null, that will be filled with default value. @@ -407,7 +362,6 @@ namespace System.Data.Common } return counter; } -#endif // NET_2_0 public override DataTable [] FillSchema (DataSet dataSet, SchemaType schemaType) { @@ -659,7 +613,7 @@ namespace System.Data.Common } RowUpdatingEventArgs argsUpdating = CreateRowUpdatingEvent (row, command, statementType, tableMapping); - row.RowError = null; + row.RowError = String.Empty; OnRowUpdating (argsUpdating); switch (argsUpdating.Status) { case UpdateStatus.Continue : @@ -684,9 +638,6 @@ namespace System.Data.Common try { if (command != null) { DataColumnMappingCollection columnMappings = tableMapping.ColumnMappings; -#if ONLY_1_1 - IDataParameter nullCheckParam = null; -#endif foreach (IDataParameter parameter in command.Parameters) { if ((parameter.Direction & ParameterDirection.Input) == 0) continue; @@ -697,7 +648,6 @@ namespace System.Data.Common rowVersion = DataRowVersion.Original; string dsColumnName = parameter.SourceColumn; -#if NET_2_0 if (columnMappings.Contains(dsColumnName)) { dsColumnName = columnMappings [dsColumnName].DataSetColumn; parameter.Value = row [dsColumnName, rowVersion]; @@ -706,21 +656,8 @@ namespace System.Data.Common } DbParameter nullCheckParam = parameter as DbParameter; -#else - if (columnMappings.Contains(dsColumnName)) - dsColumnName = columnMappings [dsColumnName].DataSetColumn; - if (dsColumnName == null || dsColumnName.Length == 0) { - nullCheckParam = parameter; - continue; - } - parameter.Value = row [dsColumnName, rowVersion]; -#endif -#if NET_2_0 if (nullCheckParam != null && nullCheckParam.SourceColumnNullMapping) { -#else - if (nullCheckParam != null) { -#endif if (parameter.Value != null && parameter.Value != DBNull.Value) nullCheckParam.Value = 0; else @@ -836,10 +773,8 @@ namespace System.Data.Common case UpdateStatus.SkipAllRemainingRows: return updateCount; } -#if NET_2_0 if (!AcceptChangesDuringUpdate) continue; -#endif row.AcceptChanges (); } catch (Exception e) { row.RowError = e.Message; @@ -866,10 +801,31 @@ namespace System.Data.Common if (dataTable == null) throw new ArgumentException (String.Format ("Missing table {0}", srcTable)); + + /** Copied from another Update function **/ + if (tableMapping != null) { + foreach (DataColumn col in dataTable.Columns) { + if (tableMapping.ColumnMappings.IndexOf (col.ColumnName) >= 0) + continue; + DataColumnMapping columnMapping = DataColumnMappingCollection.GetColumnMappingBySchemaAction (tableMapping.ColumnMappings, col.ColumnName, MissingMappingAction); + if (columnMapping == null) + columnMapping = new DataColumnMapping (col.ColumnName, col.ColumnName); + tableMapping.ColumnMappings.Add (columnMapping); + } + } else { + ArrayList cmc = new ArrayList (); + foreach (DataColumn col in dataTable.Columns) + cmc.Add (new DataColumnMapping (col.ColumnName, col.ColumnName)); + tableMapping = + new DataTableMapping ( + dataTable.TableName, + dataTable.TableName, + cmc.ToArray (typeof (DataColumnMapping)) as DataColumnMapping []); + } + /**end insert from another update**/ return Update (dataTable, tableMapping); } -#if NET_2_0 // All the batch methods, should be implemented, if supported, // by individual providers @@ -914,18 +870,6 @@ namespace System.Data.Common { return new NotSupportedException ("Method is not supported."); } -#else - internal override void OnFillErrorInternal (FillErrorEventArgs value) - { - OnFillError (value); - } - - protected virtual void OnFillError (FillErrorEventArgs value) - { - if (FillError != null) - FillError (this, value); - } -#endif #endregion // Methods } }