using System;
using System.Data;
+#if NET_2_0
+using System.Data.Common;
+#endif
namespace Mono.Data.SqliteClient
{
- public sealed class SqliteTransaction : IDbTransaction
+ public sealed class SqliteTransaction :
+#if NET_2_0
+ DbTransaction
+#else
+ IDbTransaction
+#endif
{
#region Fields
_open = true;
}
- void System.IDisposable.Dispose()
+#if !NET_2_0
+ void System.IDisposable.Dispose()
{
}
-
+#endif
+
#endregion
#region Public Properties
+#if NET_2_0
+ protected override DbConnection DbConnection
+#else
public IDbConnection Connection
+#endif
{
get { return _connection; }
+#if !NET_2_0
set { _connection = (SqliteConnection)value; }
+#endif
}
- public IsolationLevel IsolationLevel
+#if NET_2_0
+ override
+#endif
+ public IsolationLevel IsolationLevel
{
get { return _isolationLevel; }
+#if !NET_2_0
set { _isolationLevel = value; }
+#endif
+ }
+
+#if NET_2_0
+ internal void SetConnection (DbConnection conn)
+ {
+ _connection = (SqliteConnection)conn;
}
+ internal void SetIsolationLevel (IsolationLevel level)
+ {
+ _isolationLevel = level;
+ }
+#endif
+
#endregion
#region Public Methods
-
+
+#if NET_2_0
+ override
+#endif
public void Commit()
{
if (_connection == null || _connection.State != ConnectionState.Open)
throw new InvalidOperationException("Transaction has already been committed or is not pending");
try
{
- SqliteCommand cmd = _connection.CreateCommand();
+ SqliteCommand cmd = (SqliteCommand)_connection.CreateCommand();
cmd.CommandText = "COMMIT";
cmd.ExecuteNonQuery();
_open = false;
}
}
+#if NET_2_0
+ override
+#endif
public void Rollback()
{
if (_connection == null || _connection.State != ConnectionState.Open)
throw new InvalidOperationException("Transaction has already been rolled back or is not pending");
try
{
- SqliteCommand cmd = _connection.CreateCommand();
+ SqliteCommand cmd = (SqliteCommand)_connection.CreateCommand();
cmd.CommandText = "ROLLBACK";
cmd.ExecuteNonQuery();
_open = false;