mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-17 01:41:17 -10:00
OdbcCommandTest.cs, OdbcConnectionTest.cs, OdbcDataAdapterTest.cs, OleDbCommandTest.cs, OleDbConnectionTest.cs, OleDbDataAdapterTest.cs, SqlDataAdapterTest.cs. * DbDataAdapter.cs: Implemented UpdateBatchSize setter. * DataAdapter.cs: In FillLoadOption setter, ensure value is valid. Modified MissingMappingAction and MissingSchemaAction setters to use ExceptionHelper.CheckEnumValue to validate value. Spaces to tabs and code formatting. * ExceptionHelper.cs: Added CheckEnumValue method and modified InvalidEnumValueException method to return AORE on 2.0 profile. Added ConnectionClosed method that returns an InvalidOperationException. * OleDbDataAdapter.cs: In default ctor, set SelectCommand to null. Only initialize SelectCommand in ctors. Use direct assignment in IDbDataAdapter implementation. * OleDbCommand.cs: Added constant for default CommandTimeout, instead of using a magic number. Avoid unnecessary initialization. Fixed default value for DesignTimeVisible. Return zero-length string if CommandText is null. Added implementation for UpdatedRowSource. * OleDbConnection.cs: Moved initialization of gda to Open (). Avoid unnecessary initialization. Return zero-length string if ConnectionString is null. If getters to Database, DataSource and Provider return zero-length string if the connection is closed. In ServerVersion, BeginTransaction and GetSchema, throw an InvalidOperationException if connection is closed. * OdbcCommand.cs: Added constant for default CommandTimeout, instead of using a magic number. Avoid unnecessary initialization. Fixed default value for DesignTimeVisible. Return zero-length string if CommandText is null. Spaces to tabs and code formatting. * OdbcError.cs: Fixed typo in exception message. * OdbcConnection.cs: Return zero-length string if ConnectionString is null. In getters for Database, DataSource and Driver return a zero-length string if connection is closed. In BeginTransaction and GetSchema throw InvalidOperationException if connection is closed. Added override for GetSchema (string, string []). Use string.Empty instead of "". * OdbcDataAdapter.cs: Avoid unnecessary initializations. Use direct assignment in IDbDataAdapter implementation. In default ctor, set SelectCommand to null. * SqlCommand.cs: Added constant for default CommandTimeout, instead of using a magic number. Avoid unnecessary initialization. Fixed default value for DesignTimeVisible. Return zero-length string if CommandText is null. Use ExceptionHelper.InvalidEnumValueException to avoid code duplication. Spaces to tabs and code formatting. * SqlConnection.cs: Use different default package size on 2.0 profile. Added constants for default values, instead of using magic numbers. Avoid unnecessary initialization. In PacketSize, return default or configured packet size when connection is not open. Use ExceptionHelper.ConnectionClosed instead of local method. Removed use of some hardcoded values in SetDefaultConnectionParameters, and use Environment.MachineName as default WorkstationId instead of DNS host name. Code formatting. * SqlDataAdapter.cs: In default ctor, set SelectCommand to null. Avoid unnecessary initializations. Use direct assignment in IDbDataAdapter implementation. Fixed exception message for negative UpdateBatchSize. In Dispose override, make sure to invoke base method. * DbDataAdapterTest.cs: Added test for UpdateBatchSize. * DataAdapterTest.cs: Added tests for AcceptChangesDuringFile, AcceptChangesDuringUpdate, ContinueUpdateOnError, FillLoadOption, MissingMappingAction, MissingSchemaAction and ReturnProviderSpecificTypes. * OdbcDataAdapterTest.cs: Added tests for ctors, DeleteCommand, InsertCommand, SelectCommand, UpdateCommand and Dispose. * OdbcDataReaderTest.cs: fixed line endings. * OdbcCommandTest.cs: Added tests for ctors and CommantText. * OdbcConnectionTest.cs: Removed original test that relied on MySQL. Added ctor tests. Added tests for BeginTransaction, GetSchema and ServerVersion with connection that is closed. * OleDbDataAdapterTest.cs: Added tests for ctors, DeleteCommand, InsertCommand, SelectCommand, UpdateCommand and Dispose. * OleDbCommandTest.cs: Added tests for ctors and CommandText. * OleDbConnectionTest.cs: Added tests for ctors and ConnectionString. Added tests for BeginTransaction, GetSchema and ServerVersion with connection that is closed. * SqlCommandTest.cs: Added tests for ctors and CommantText. * SqlConnectionTest.cs: Added tests for ctors, ConnectionString and ServerVersion. * SqlDataAdapterTest.cs: Added tests for ctors, DeleteCommand, InsertCommand, SelectCommand, UpdateCommand, UpdateBatchSize and Dispose. svn path=/trunk/mcs/; revision=87859
266 lines
7.5 KiB
C#
266 lines
7.5 KiB
C#
//
|
|
// System.Data.SqlClient.SqlDataAdapter.cs
|
|
//
|
|
// Author:
|
|
// Rodrigo Moya ([email protected])
|
|
// Daniel Morgan ([email protected])
|
|
// Tim Coleman ([email protected])
|
|
//
|
|
// (C) Ximian, Inc 2002
|
|
// Copyright (C) 2002 Tim Coleman
|
|
//
|
|
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining
|
|
// a copy of this software and associated documentation files (the
|
|
// "Software"), to deal in the Software without restriction, including
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
// distribute, sublicense, and/or sell copies of the Software, and to
|
|
// permit persons to whom the Software is furnished to do so, subject to
|
|
// the following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be
|
|
// included in all copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
//
|
|
|
|
using System;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Data.Common;
|
|
|
|
namespace System.Data.SqlClient {
|
|
[DefaultEvent ("RowUpdated")]
|
|
[DesignerAttribute ("Microsoft.VSDesigner.Data.VS.SqlDataAdapterDesigner, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.ComponentModel.Design.IDesigner")]
|
|
[ToolboxItemAttribute ("Microsoft.VSDesigner.Data.VS.SqlDataAdapterToolboxItem, "+ Consts.AssemblyMicrosoft_VSDesigner)]
|
|
public sealed class SqlDataAdapter : DbDataAdapter, IDbDataAdapter, ICloneable
|
|
{
|
|
#region Fields
|
|
|
|
#if !NET_2_0
|
|
bool disposed;
|
|
#endif
|
|
SqlCommand deleteCommand;
|
|
SqlCommand insertCommand;
|
|
SqlCommand selectCommand;
|
|
SqlCommand updateCommand;
|
|
#if NET_2_0
|
|
int updateBatchSize;
|
|
#endif
|
|
#endregion
|
|
|
|
#region Constructors
|
|
|
|
public SqlDataAdapter () : this ((SqlCommand) null)
|
|
{
|
|
}
|
|
|
|
public SqlDataAdapter (SqlCommand selectCommand)
|
|
{
|
|
SelectCommand = selectCommand;
|
|
#if NET_2_0
|
|
UpdateBatchSize = 1;
|
|
#endif
|
|
}
|
|
|
|
public SqlDataAdapter (string selectCommandText, SqlConnection selectConnection)
|
|
: this (new SqlCommand (selectCommandText, selectConnection))
|
|
{
|
|
}
|
|
|
|
public SqlDataAdapter (string selectCommandText, string selectConnectionString)
|
|
: this (selectCommandText, new SqlConnection (selectConnectionString))
|
|
{
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Properties
|
|
|
|
#if !NET_2_0
|
|
[DataSysDescription ("Used during Update for deleted rows in DataSet.")]
|
|
#endif
|
|
[DefaultValue (null)]
|
|
[EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
|
|
public new SqlCommand DeleteCommand {
|
|
get { return deleteCommand; }
|
|
set { deleteCommand = value; }
|
|
}
|
|
|
|
#if !NET_2_0
|
|
[DataSysDescription ("Used during Update for new rows in DataSet.")]
|
|
#endif
|
|
[DefaultValue (null)]
|
|
[EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
|
|
public new SqlCommand InsertCommand {
|
|
get { return insertCommand; }
|
|
set { insertCommand = value; }
|
|
}
|
|
|
|
#if !NET_2_0
|
|
[DataSysDescription ("Used during Fill/FillSchema.")]
|
|
#endif
|
|
[DefaultValue (null)]
|
|
[EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
|
|
public new SqlCommand SelectCommand {
|
|
get { return selectCommand; }
|
|
set { selectCommand = value; }
|
|
}
|
|
|
|
#if !NET_2_0
|
|
[DataSysDescription ("Used during Update for modified rows in DataSet.")]
|
|
#endif
|
|
[DefaultValue (null)]
|
|
[EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
|
|
public new SqlCommand UpdateCommand {
|
|
get { return updateCommand; }
|
|
set { updateCommand = value; }
|
|
}
|
|
|
|
IDbCommand IDbDataAdapter.DeleteCommand {
|
|
get { return DeleteCommand; }
|
|
set { DeleteCommand = (SqlCommand) value; }
|
|
}
|
|
|
|
IDbCommand IDbDataAdapter.InsertCommand {
|
|
get { return InsertCommand; }
|
|
set { InsertCommand = (SqlCommand) value; }
|
|
}
|
|
|
|
IDbCommand IDbDataAdapter.SelectCommand {
|
|
get { return SelectCommand; }
|
|
set { SelectCommand = (SqlCommand) value; }
|
|
}
|
|
|
|
IDbCommand IDbDataAdapter.UpdateCommand {
|
|
get { return UpdateCommand; }
|
|
set { UpdateCommand = (SqlCommand) value; }
|
|
}
|
|
|
|
ITableMappingCollection IDataAdapter.TableMappings {
|
|
get { return TableMappings; }
|
|
}
|
|
|
|
#if NET_2_0
|
|
public override int UpdateBatchSize {
|
|
get { return updateBatchSize; }
|
|
set {
|
|
if (value < 0)
|
|
throw new ArgumentOutOfRangeException ("UpdateBatchSize");
|
|
updateBatchSize = value;
|
|
}
|
|
}
|
|
#endif
|
|
|
|
#endregion // Properties
|
|
|
|
#region Methods
|
|
|
|
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);
|
|
}
|
|
|
|
#if !NET_2_0
|
|
protected override void Dispose (bool disposing)
|
|
{
|
|
if (!disposed) {
|
|
if (disposing) {
|
|
// Release managed resources
|
|
}
|
|
// Release unmanaged resources
|
|
disposed = true;
|
|
}
|
|
base.Dispose (disposing);
|
|
}
|
|
#endif
|
|
|
|
protected override void OnRowUpdated (RowUpdatedEventArgs value)
|
|
{
|
|
if (RowUpdated != null)
|
|
RowUpdated (this, (SqlRowUpdatedEventArgs) value);
|
|
}
|
|
|
|
protected override void OnRowUpdating (RowUpdatingEventArgs value)
|
|
{
|
|
if (RowUpdating != null)
|
|
RowUpdating (this, (SqlRowUpdatingEventArgs) value);
|
|
}
|
|
|
|
[MonoTODO]
|
|
object ICloneable.Clone()
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
#if NET_2_0
|
|
// All the batch methods, should be implemented, if supported,
|
|
// by individual providers
|
|
|
|
[MonoTODO]
|
|
protected override int AddToBatch (IDbCommand cmd)
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
[MonoTODO]
|
|
protected override void ClearBatch ()
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
[MonoTODO]
|
|
protected override int ExecuteBatch ()
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
[MonoTODO]
|
|
protected override IDataParameter GetBatchedParameter (int commandIdentifier, int parameterIdentifer)
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
[MonoTODO]
|
|
protected override void InitializeBatching ()
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
[MonoTODO]
|
|
protected override void TerminateBatching ()
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
#endif
|
|
#endregion // Methods
|
|
|
|
#region Events and Delegates
|
|
|
|
#if ONLY_1_1
|
|
[DataSysDescription ("Event triggered before every DataRow during Update.")]
|
|
#endif
|
|
public event SqlRowUpdatedEventHandler RowUpdated;
|
|
|
|
#if ONLY_1_1
|
|
[DataSysDescription ("Event triggered after every DataRow during Update.")]
|
|
#endif
|
|
public event SqlRowUpdatingEventHandler RowUpdating;
|
|
|
|
#endregion // Events and Delegates
|
|
}
|
|
}
|