mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-17 19:10:23 -10:00
* list:
Add Mono.Data.TdsClient.Internal.TdsInternalError
Add Mono.Data.TdsClient.Internal.TdsInternalErrorCollection
Add Mono.Data.TdsClient.Internal.TdsInternalErrorMessageEventHandler
Add Mono.Data.TdsClient.Internal.TdsInternalErrorMessageEventArgs
Add Mono.Data.TdsClient.Internal.TdsInternalInfoMessageEventHandler
Add Mono.Data.TdsClient.Internal.TdsInternalInfoMessageEventArgs
Remove Mono.Data.TdsClient.Internal.TdsPacketErrorResult
Remove Mono.Data.TdsClient.Internal.TdsPacketErrorResultCollection
Remove Mono.Data.TdsClient.Internal.TdsPacketMessageResult
* System.Data.Common/RowUpdatedEventArgs.cs:
* System.Data.Common/RowUpdatingEventArgs.cs:
Implement
* System.Data.SqlClient/SqlCommand.cs:
* System.Data.SqlClient/SqlDataReader.cs:
* System.Data.SqlClient/SqlTransaction.cs:
Remove checks for errors. These are now handled by events
* System.Data.SqlClient/SqlConnection.cs:
* System.Data.SqlClient/SqlError.cs:
* System.Data.SqlClient/SqlException.cs:
* System.Data.SqlClient/SqlInfoMessageEventArgs.cs:
Add event handlers and triggers for errors, messages, state change
* System.Data.SqlClient/SqlParameter.cs:
Re-add refreshproperties
* System.Data.SqlClient/SqlRowUpdatedEventArgs.cs:
* System.Data.SqlClient/SqlRowUpdatedEventHandler.cs:
* System.Data.SqlClient/SqlRowUpdatingEventArgs.cs:
* System.Data.SqlClient/SqlRowUpdatingEventHandler.cs:
Implement
svn path=/trunk/mcs/; revision=8825
126 lines
2.8 KiB
C#
126 lines
2.8 KiB
C#
//
|
|
// System.Data.SqlClient.SqlTransaction.cs
|
|
//
|
|
// Author:
|
|
// Tim Coleman ([email protected])
|
|
//
|
|
// Copyright (C) Tim Coleman, 2002
|
|
//
|
|
|
|
using Mono.Data.TdsClient;
|
|
using System;
|
|
using System.Data;
|
|
using System.Data.Common;
|
|
|
|
namespace System.Data.SqlClient {
|
|
public sealed class SqlTransaction : MarshalByRefObject, IDbTransaction, IDisposable
|
|
{
|
|
#region Fields
|
|
|
|
SqlConnection connection;
|
|
IsolationLevel isolationLevel;
|
|
bool isOpen;
|
|
|
|
#endregion
|
|
|
|
#region Constructors
|
|
|
|
internal SqlTransaction (SqlConnection connection, IsolationLevel isolevel)
|
|
{
|
|
SetIsolationLevel (connection, isolevel);
|
|
this.connection = connection;
|
|
this.isolationLevel = isolevel;
|
|
isOpen = true;
|
|
}
|
|
|
|
#endregion // Constructors
|
|
|
|
#region Properties
|
|
|
|
public SqlConnection Connection {
|
|
get { return connection; }
|
|
}
|
|
|
|
internal bool IsOpen {
|
|
get { return isOpen; }
|
|
}
|
|
|
|
public IsolationLevel IsolationLevel {
|
|
get { return isolationLevel; }
|
|
}
|
|
|
|
IDbConnection IDbTransaction.Connection {
|
|
get { return Connection; }
|
|
}
|
|
|
|
#endregion // Properties
|
|
|
|
#region Methods
|
|
|
|
static void SetIsolationLevel (SqlConnection connection, IsolationLevel isolevel)
|
|
{
|
|
string commandText = "SET TRANSACTION ISOLATION LEVEL ";
|
|
|
|
switch (isolevel) {
|
|
case IsolationLevel.Chaos :
|
|
commandText += "CHAOS";
|
|
break;
|
|
case IsolationLevel.ReadCommitted :
|
|
commandText += "READ COMMITTED";
|
|
break;
|
|
case IsolationLevel.ReadUncommitted :
|
|
commandText += "READ UNCOMMITTED";
|
|
break;
|
|
case IsolationLevel.RepeatableRead :
|
|
commandText += "REPEATABLE READ";
|
|
break;
|
|
case IsolationLevel.Serializable :
|
|
commandText += "SERIALIZABLE";
|
|
break;
|
|
default :
|
|
return;
|
|
}
|
|
connection.Tds.ExecuteNonQuery (commandText);
|
|
}
|
|
|
|
public void Commit ()
|
|
{
|
|
if (!isOpen)
|
|
throw new InvalidOperationException ("The Transaction was not open.");
|
|
connection.Tds.ExecuteNonQuery ("IF @@TRANCOUNT>0 COMMIT TRAN");
|
|
isOpen = false;
|
|
}
|
|
|
|
[MonoTODO]
|
|
public void Dispose ()
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
public void Rollback ()
|
|
{
|
|
if (!isOpen)
|
|
throw new InvalidOperationException ("The Transaction was not open.");
|
|
connection.Tds.ExecuteNonQuery ("IF @@TRANCOUNT>0 ROLLBACK TRAN");
|
|
isOpen = false;
|
|
}
|
|
|
|
public void Rollback (string transactionName)
|
|
{
|
|
if (!isOpen)
|
|
throw new InvalidOperationException ("The Transaction was not open.");
|
|
connection.Tds.ExecuteNonQuery (String.Format ("IF @@TRANCOUNT > 0 ROLLBACK TRAN {0}", transactionName));
|
|
isOpen = false;
|
|
}
|
|
|
|
public void Save (string savePointName)
|
|
{
|
|
if (!isOpen)
|
|
throw new InvalidOperationException ("The Transaction was not open.");
|
|
connection.Tds.ExecuteNonQuery (String.Format ("SAVE TRAN {0}", savePointName));
|
|
}
|
|
|
|
#endregion // Methods
|
|
}
|
|
}
|