From 01ab15e12c36dc5a9016c0000439c24e0d50a364 Mon Sep 17 00:00:00 2001 From: Lawrence LCI Date: Mon, 27 Sep 2021 15:50:57 -0700 Subject: [PATCH 1/3] Move the netcore version of SqlDataAdapter into shared src and update the references in the netfx csproj --- .../src/Microsoft.Data.SqlClient.csproj | 4 +- .../netfx/src/Microsoft.Data.SqlClient.csproj | 6 +- .../Data/SqlClient/SqlDataAdapter.cs | 331 ------------------ .../Data/SqlClient/SqlDataAdapter.cs | 0 4 files changed, 7 insertions(+), 334 deletions(-) delete mode 100644 src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs rename src/Microsoft.Data.SqlClient/{netcore => }/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs (100%) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj index d918134b15..130aff2643 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj @@ -220,6 +220,9 @@ Microsoft\Data\SqlClient\SqlCredential.cs + + Microsoft\Data\SqlClient\SqlDataAdapter.cs + Microsoft\Data\SqlClient\SqlInfoMessageEventHandler.cs @@ -491,7 +494,6 @@ Microsoft\Data\SqlClient\SqlConnectionTimeoutErrorInternal.cs - diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj index f54e7630c6..965f35d315 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj @@ -288,6 +288,9 @@ Microsoft\Data\SqlClient\SqlConnectionPoolProviderInfo.cs + + Microsoft\Data\SqlClient\SqlDataAdapter.cs + Microsoft\Data\SqlClient\SqlEnclaveAttestationParameters.Crypto.cs @@ -430,7 +433,7 @@ - + @@ -462,7 +465,6 @@ Microsoft\Data\SqlClient\SqlCredential.cs - diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs deleted file mode 100644 index c423fd8240..0000000000 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs +++ /dev/null @@ -1,331 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.ComponentModel; -using System.Data; -using System.Data.Common; -using System.Diagnostics; -using Microsoft.Data.Common; - -namespace Microsoft.Data.SqlClient -{ - /// - [ - DefaultEvent("RowUpdated"), - DesignerCategory("") - // TODO: Add designer and toolbox attribute when Microsoft.VSDesigner.Data.VS.SqlDataAdapterDesigner uses Microsoft.Data.SqlClient - ] - public sealed class SqlDataAdapter : DbDataAdapter, IDbDataAdapter, ICloneable - { - - static private readonly object EventRowUpdated = new object(); - static private readonly object EventRowUpdating = new object(); - - private SqlCommand _deleteCommand, _insertCommand, _selectCommand, _updateCommand; - - private SqlCommandSet _commandSet; - private int _updateBatchSize = 1; - - private static int _objectTypeCount; // EventSource Counter - internal readonly int _objectID = System.Threading.Interlocked.Increment(ref _objectTypeCount); - - internal int ObjectID - { - get - { - return _objectID; - } - } - /// - public SqlDataAdapter() : base() - { - GC.SuppressFinalize(this); - } - - /// - public SqlDataAdapter(SqlCommand selectCommand) : this() - { - SelectCommand = selectCommand; - } - - /// - public SqlDataAdapter(string selectCommandText, string selectConnectionString) : this() - { - SqlConnection connection = new SqlConnection(selectConnectionString); - SelectCommand = new SqlCommand(selectCommandText, connection); - } - - /// - public SqlDataAdapter(string selectCommandText, SqlConnection selectConnection) : this() - { - SelectCommand = new SqlCommand(selectCommandText, selectConnection); - } - - private SqlDataAdapter(SqlDataAdapter from) : base(from) - { // Clone - GC.SuppressFinalize(this); - } - - /// - [ - DefaultValue(null), - Editor("Microsoft.VSDesigner.Data.Design.DBCommandEditor, " + AssemblyRef.MicrosoftVSDesigner, "System.Drawing.Design.UITypeEditor, " + AssemblyRef.SystemDrawing), - ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Update), - ResDescriptionAttribute(StringsHelper.ResourceNames.DbDataAdapter_DeleteCommand), - ] - new public SqlCommand DeleteCommand - { - get { return _deleteCommand; } - set { _deleteCommand = value; } - } - - /// - IDbCommand IDbDataAdapter.DeleteCommand - { - get { return _deleteCommand; } - set { _deleteCommand = (SqlCommand)value; } - } - - /// - [ - DefaultValue(null), - Editor("Microsoft.VSDesigner.Data.Design.DBCommandEditor, " + AssemblyRef.MicrosoftVSDesigner, "System.Drawing.Design.UITypeEditor, " + AssemblyRef.SystemDrawing), - ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Update), - ResDescriptionAttribute(StringsHelper.ResourceNames.DbDataAdapter_InsertCommand), - ] - new public SqlCommand InsertCommand - { - get { return _insertCommand; } - set { _insertCommand = value; } - } - - /// - IDbCommand IDbDataAdapter.InsertCommand - { - get { return _insertCommand; } - set { _insertCommand = (SqlCommand)value; } - } - - /// - [ - DefaultValue(null), - Editor("Microsoft.VSDesigner.Data.Design.DBCommandEditor, " + AssemblyRef.MicrosoftVSDesigner, "System.Drawing.Design.UITypeEditor, " + AssemblyRef.SystemDrawing), - ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Fill), - ResDescriptionAttribute(StringsHelper.ResourceNames.DbDataAdapter_SelectCommand), - ] - new public SqlCommand SelectCommand - { - get { return _selectCommand; } - set { _selectCommand = value; } - } - - /// - IDbCommand IDbDataAdapter.SelectCommand - { - get { return _selectCommand; } - set { _selectCommand = (SqlCommand)value; } - } - - /// - override public int UpdateBatchSize - { - get - { - return _updateBatchSize; - } - set - { - if (0 > value) - { // WebData 98157 - throw ADP.ArgumentOutOfRange("UpdateBatchSize"); - } - _updateBatchSize = value; - SqlClientEventSource.Log.TryTraceEvent(" {0}, {1}", ObjectID, value); - } - } - - /// - [ - DefaultValue(null), - Editor("Microsoft.VSDesigner.Data.Design.DBCommandEditor, " + AssemblyRef.MicrosoftVSDesigner, "System.Drawing.Design.UITypeEditor, " + AssemblyRef.SystemDrawing), - ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Update), - ResDescriptionAttribute(StringsHelper.ResourceNames.DbDataAdapter_UpdateCommand), - ] - new public SqlCommand UpdateCommand - { - get { return _updateCommand; } - set { _updateCommand = value; } - } - - /// - IDbCommand IDbDataAdapter.UpdateCommand - { - get { return _updateCommand; } - set { _updateCommand = (SqlCommand)value; } - } - - /// - [ - ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Update), - ResDescriptionAttribute(StringsHelper.ResourceNames.DbDataAdapter_RowUpdated), - ] - public event SqlRowUpdatedEventHandler RowUpdated - { - add - { - Events.AddHandler(EventRowUpdated, value); - } - remove - { - Events.RemoveHandler(EventRowUpdated, value); - } - } - - /// - [ - ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Update), - ResDescriptionAttribute(StringsHelper.ResourceNames.DbDataAdapter_RowUpdating), - ] - public event SqlRowUpdatingEventHandler RowUpdating - { - add - { - SqlRowUpdatingEventHandler handler = (SqlRowUpdatingEventHandler)Events[EventRowUpdating]; - - // MDAC 58177, 64513 - // prevent someone from registering two different command builders on the adapter by - // silently removing the old one - if ((null != handler) && (value.Target is DbCommandBuilder)) - { - SqlRowUpdatingEventHandler d = (SqlRowUpdatingEventHandler)ADP.FindBuilder(handler); - if (null != d) - { - Events.RemoveHandler(EventRowUpdating, d); - } - } - Events.AddHandler(EventRowUpdating, value); - } - remove - { - Events.RemoveHandler(EventRowUpdating, value); - } - } - - /// - override protected int AddToBatch(IDbCommand command) - { - int commandIdentifier = _commandSet.CommandCount; - _commandSet.Append((SqlCommand)command); - return commandIdentifier; - } - - /// - override protected void ClearBatch() - { - _commandSet.Clear(); - } - - /// - object ICloneable.Clone() - { - return new SqlDataAdapter(this); - } - - /// - override protected RowUpdatedEventArgs CreateRowUpdatedEvent(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) - { - return new SqlRowUpdatedEventArgs(dataRow, command, statementType, tableMapping); - } - - /// - override protected RowUpdatingEventArgs CreateRowUpdatingEvent(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) - { - return new SqlRowUpdatingEventArgs(dataRow, command, statementType, tableMapping); - } - - /// - override protected int ExecuteBatch() - { - Debug.Assert(null != _commandSet && (0 < _commandSet.CommandCount), "no commands"); - SqlClientEventSource.Log.TryCorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); - - return _commandSet.ExecuteNonQuery(); - } - - /// - override protected IDataParameter GetBatchedParameter(int commandIdentifier, int parameterIndex) - { - Debug.Assert(commandIdentifier < _commandSet.CommandCount, "commandIdentifier out of range"); - Debug.Assert(parameterIndex < _commandSet.GetParameterCount(commandIdentifier), "parameter out of range"); - IDataParameter parameter = _commandSet.GetParameter(commandIdentifier, parameterIndex); - return parameter; - } - - /// - override protected bool GetBatchedRecordsAffected(int commandIdentifier, out int recordsAffected, out Exception error) - { - Debug.Assert(commandIdentifier < _commandSet.CommandCount, "commandIdentifier out of range"); - return _commandSet.GetBatchedAffected(commandIdentifier, out recordsAffected, out error); - } - - /// - override protected void InitializeBatching() - { - SqlClientEventSource.Log.TryTraceEvent(" {0}", ObjectID); - _commandSet = new SqlCommandSet(); - SqlCommand command = SelectCommand; - if (null == command) - { - command = InsertCommand; - if (null == command) - { - command = UpdateCommand; - if (null == command) - { - command = DeleteCommand; - } - } - } - if (null != command) - { - _commandSet.Connection = command.Connection; - _commandSet.Transaction = command.Transaction; - _commandSet.CommandTimeout = command.CommandTimeout; - } - } - - /// - override protected void OnRowUpdated(RowUpdatedEventArgs value) - { - SqlRowUpdatedEventHandler handler = (SqlRowUpdatedEventHandler)Events[EventRowUpdated]; - if ((null != handler) && (value is SqlRowUpdatedEventArgs)) - { - handler(this, (SqlRowUpdatedEventArgs)value); - } - base.OnRowUpdated(value); - } - - /// - override protected void OnRowUpdating(RowUpdatingEventArgs value) - { - SqlRowUpdatingEventHandler handler = (SqlRowUpdatingEventHandler)Events[EventRowUpdating]; - if ((null != handler) && (value is SqlRowUpdatingEventArgs)) - { - handler(this, (SqlRowUpdatingEventArgs)value); - } - base.OnRowUpdating(value); - } - - /// - override protected void TerminateBatching() - { - if (null != _commandSet) - { - _commandSet.Dispose(); - _commandSet = null; - } - } - } -} diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs similarity index 100% rename from src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs From b625a2406abe8bdcb97d19e2367fe1c8ff18a08f Mon Sep 17 00:00:00 2001 From: Lawrence LCI Date: Mon, 27 Sep 2021 15:54:29 -0700 Subject: [PATCH 2/3] Fix compiler error due to the include file paths for the documentation due to the path change to shared src --- .../Data/SqlClient/SqlDataAdapter.cs | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs index 1e620841a7..b00bb02237 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs @@ -12,7 +12,7 @@ namespace Microsoft.Data.SqlClient { - /// + /// [DefaultEvent("RowUpdated")] [DesignerCategory("")] // TODO: Add designer and toolbox attribute when Microsoft.VSDesigner.Data.VS.SqlDataAdapterDesigner uses Microsoft.Data.SqlClient @@ -31,26 +31,26 @@ public sealed class SqlDataAdapter : DbDataAdapter, IDbDataAdapter, ICloneable internal int ObjectID => _objectID; - /// + /// public SqlDataAdapter() : base() { GC.SuppressFinalize(this); } - /// + /// public SqlDataAdapter(SqlCommand selectCommand) : this() { SelectCommand = selectCommand; } - /// + /// public SqlDataAdapter(string selectCommandText, string selectConnectionString) : this() { SqlConnection connection = new SqlConnection(selectConnectionString); SelectCommand = new SqlCommand(selectCommandText, connection); } - /// + /// public SqlDataAdapter(string selectCommandText, SqlConnection selectConnection) : this() { SelectCommand = new SqlCommand(selectCommandText, selectConnection); @@ -61,7 +61,7 @@ private SqlDataAdapter(SqlDataAdapter from) : base(from) GC.SuppressFinalize(this); } - /// + /// [DefaultValue(null)] [Editor("Microsoft.VSDesigner.Data.Design.DBCommandEditor, " + AssemblyRef.MicrosoftVSDesigner, "System.Drawing.Design.UITypeEditor, " + AssemblyRef.SystemDrawing)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Update)] @@ -72,14 +72,14 @@ private SqlDataAdapter(SqlDataAdapter from) : base(from) set { _deleteCommand = value; } } - /// + /// IDbCommand IDbDataAdapter.DeleteCommand { get { return _deleteCommand; } set { _deleteCommand = (SqlCommand)value; } } - /// + /// [DefaultValue(null)] [Editor("Microsoft.VSDesigner.Data.Design.DBCommandEditor, " + AssemblyRef.MicrosoftVSDesigner, "System.Drawing.Design.UITypeEditor, " + AssemblyRef.SystemDrawing)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Update)] @@ -90,14 +90,14 @@ IDbCommand IDbDataAdapter.DeleteCommand set { _insertCommand = value; } } - /// + /// IDbCommand IDbDataAdapter.InsertCommand { get { return _insertCommand; } set { _insertCommand = (SqlCommand)value; } } - /// + /// [DefaultValue(null)] [Editor("Microsoft.VSDesigner.Data.Design.DBCommandEditor, " + AssemblyRef.MicrosoftVSDesigner, "System.Drawing.Design.UITypeEditor, " + AssemblyRef.SystemDrawing)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Fill)] @@ -108,14 +108,14 @@ IDbCommand IDbDataAdapter.InsertCommand set { _selectCommand = value; } } - /// + /// IDbCommand IDbDataAdapter.SelectCommand { get { return _selectCommand; } set { _selectCommand = (SqlCommand)value; } } - /// + /// [DefaultValue(null)] [Editor("Microsoft.VSDesigner.Data.Design.DBCommandEditor, " + AssemblyRef.MicrosoftVSDesigner, "System.Drawing.Design.UITypeEditor, " + AssemblyRef.SystemDrawing)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Update)] @@ -126,14 +126,14 @@ IDbCommand IDbDataAdapter.SelectCommand set { _updateCommand = value; } } - /// + /// IDbCommand IDbDataAdapter.UpdateCommand { get { return _updateCommand; } set { _updateCommand = (SqlCommand)value; } } - /// + /// public override int UpdateBatchSize { get @@ -151,7 +151,7 @@ public override int UpdateBatchSize } } - /// + /// protected override int AddToBatch(IDbCommand command) { int commandIdentifier = _commandSet.CommandCount; @@ -159,13 +159,13 @@ protected override int AddToBatch(IDbCommand command) return commandIdentifier; } - /// + /// protected override void ClearBatch() { _commandSet.Clear(); } - /// + /// protected override int ExecuteBatch() { Debug.Assert(null != _commandSet && (0 < _commandSet.CommandCount), "no commands"); @@ -173,7 +173,7 @@ protected override int ExecuteBatch() return _commandSet.ExecuteNonQuery(); } - /// + /// protected override IDataParameter GetBatchedParameter(int commandIdentifier, int parameterIndex) { Debug.Assert(commandIdentifier < _commandSet.CommandCount, "commandIdentifier out of range"); @@ -182,14 +182,14 @@ protected override IDataParameter GetBatchedParameter(int commandIdentifier, int return parameter; } - /// + /// protected override bool GetBatchedRecordsAffected(int commandIdentifier, out int recordsAffected, out Exception error) { Debug.Assert(commandIdentifier < _commandSet.CommandCount, "commandIdentifier out of range"); return _commandSet.GetBatchedAffected(commandIdentifier, out recordsAffected, out error); } - /// + /// protected override void InitializeBatching() { SqlClientEventSource.Log.TryTraceEvent("SqlDataAdapter.InitializeBatching | API | Object Id {0}", ObjectID); @@ -215,7 +215,7 @@ protected override void InitializeBatching() } } - /// + /// protected override void TerminateBatching() { if (null != _commandSet) @@ -225,25 +225,25 @@ protected override void TerminateBatching() } } - /// + /// object ICloneable.Clone() { return new SqlDataAdapter(this); } - /// + /// protected override RowUpdatedEventArgs CreateRowUpdatedEvent(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) { return new SqlRowUpdatedEventArgs(dataRow, command, statementType, tableMapping); } - /// + /// protected override RowUpdatingEventArgs CreateRowUpdatingEvent(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) { return new SqlRowUpdatingEventArgs(dataRow, command, statementType, tableMapping); } - /// + /// [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Update)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbDataAdapter_RowUpdated)] public event SqlRowUpdatedEventHandler RowUpdated @@ -258,7 +258,7 @@ public event SqlRowUpdatedEventHandler RowUpdated } } - /// + /// [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Update)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbDataAdapter_RowUpdating)] public event SqlRowUpdatingEventHandler RowUpdating @@ -285,7 +285,7 @@ public event SqlRowUpdatingEventHandler RowUpdating } } - /// + /// override protected void OnRowUpdated(RowUpdatedEventArgs value) { SqlRowUpdatedEventHandler handler = (SqlRowUpdatedEventHandler)Events[EventRowUpdated]; @@ -296,7 +296,7 @@ override protected void OnRowUpdated(RowUpdatedEventArgs value) base.OnRowUpdated(value); } - /// + /// override protected void OnRowUpdating(RowUpdatingEventArgs value) { SqlRowUpdatingEventHandler handler = (SqlRowUpdatingEventHandler)Events[EventRowUpdating]; From a1a41201ed5f909a9709b10b931f135e65ff94cb Mon Sep 17 00:00:00 2001 From: Lawrence LCI Date: Mon, 27 Sep 2021 16:02:31 -0700 Subject: [PATCH 3/3] Update file to conform to coding style cleaning up IDE0090, IDE1006 and IDE0038 --- .../Data/SqlClient/SqlDataAdapter.cs | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs index b00bb02237..5edcc123de 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs @@ -18,16 +18,16 @@ namespace Microsoft.Data.SqlClient // TODO: Add designer and toolbox attribute when Microsoft.VSDesigner.Data.VS.SqlDataAdapterDesigner uses Microsoft.Data.SqlClient public sealed class SqlDataAdapter : DbDataAdapter, IDbDataAdapter, ICloneable { - private static readonly object EventRowUpdated = new object(); - private static readonly object EventRowUpdating = new object(); + private static readonly object s_eventRowUpdated = new(); + private static readonly object s_eventRowUpdating = new(); private SqlCommand _deleteCommand, _insertCommand, _selectCommand, _updateCommand; private SqlCommandSet _commandSet; private int _updateBatchSize = 1; - private static int _objectTypeCount; // EventSource Counter - internal readonly int _objectID = Interlocked.Increment(ref _objectTypeCount); + private static int s_objectTypeCount; // EventSource Counter + internal readonly int _objectID = Interlocked.Increment(ref s_objectTypeCount); internal int ObjectID => _objectID; @@ -46,7 +46,7 @@ public SqlDataAdapter(SqlCommand selectCommand) : this() /// public SqlDataAdapter(string selectCommandText, string selectConnectionString) : this() { - SqlConnection connection = new SqlConnection(selectConnectionString); + SqlConnection connection = new(selectConnectionString); SelectCommand = new SqlCommand(selectCommandText, connection); } @@ -250,11 +250,11 @@ public event SqlRowUpdatedEventHandler RowUpdated { add { - Events.AddHandler(EventRowUpdated, value); + Events.AddHandler(s_eventRowUpdated, value); } remove { - Events.RemoveHandler(EventRowUpdated, value); + Events.RemoveHandler(s_eventRowUpdated, value); } } @@ -265,7 +265,7 @@ public event SqlRowUpdatingEventHandler RowUpdating { add { - SqlRowUpdatingEventHandler handler = (SqlRowUpdatingEventHandler)Events[EventRowUpdating]; + SqlRowUpdatingEventHandler handler = (SqlRowUpdatingEventHandler)Events[s_eventRowUpdating]; // Prevent someone from registering two different command builders on the adapter by // silently removing the old one. @@ -274,24 +274,24 @@ public event SqlRowUpdatingEventHandler RowUpdating SqlRowUpdatingEventHandler d = (SqlRowUpdatingEventHandler)ADP.FindBuilder(handler); if (null != d) { - Events.RemoveHandler(EventRowUpdating, d); + Events.RemoveHandler(s_eventRowUpdating, d); } } - Events.AddHandler(EventRowUpdating, value); + Events.AddHandler(s_eventRowUpdating, value); } remove { - Events.RemoveHandler(EventRowUpdating, value); + Events.RemoveHandler(s_eventRowUpdating, value); } } /// override protected void OnRowUpdated(RowUpdatedEventArgs value) { - SqlRowUpdatedEventHandler handler = (SqlRowUpdatedEventHandler)Events[EventRowUpdated]; - if ((null != handler) && (value is SqlRowUpdatedEventArgs)) + SqlRowUpdatedEventHandler handler = (SqlRowUpdatedEventHandler)Events[s_eventRowUpdated]; + if ((null != handler) && (value is SqlRowUpdatedEventArgs args)) { - handler(this, (SqlRowUpdatedEventArgs)value); + handler(this, args); } base.OnRowUpdated(value); } @@ -299,10 +299,10 @@ override protected void OnRowUpdated(RowUpdatedEventArgs value) /// override protected void OnRowUpdating(RowUpdatingEventArgs value) { - SqlRowUpdatingEventHandler handler = (SqlRowUpdatingEventHandler)Events[EventRowUpdating]; - if ((null != handler) && (value is SqlRowUpdatingEventArgs)) + SqlRowUpdatingEventHandler handler = (SqlRowUpdatingEventHandler)Events[s_eventRowUpdating]; + if ((null != handler) && (value is SqlRowUpdatingEventArgs args)) { - handler(this, (SqlRowUpdatingEventArgs)value); + handler(this, args); } base.OnRowUpdating(value); }