2002-06-02 Rodrigo Moya <rodrigo@ximian.com>
[mono.git] / mcs / class / System.Data / System.Data.OleDb / OleDbTransaction.cs
1 //
2 // System.Data.OleDb.OleDbTransaction
3 //
4 // Author:
5 //   Rodrigo Moya (rodrigo@ximian.com)
6 //
7 // Copyright (C) Rodrigo Moya, 2002
8 //
9
10 using System.Data;
11 using System.Data.Common;
12 using System.Exception;
13
14 namespace System.Data.OleDb
15 {
16         public sealed class OleDbTransaction : MarshalByRefObject,
17                 IDbTransaction, IDisposable
18         {
19                 private OleDbConnection m_connection = null;
20                 private IsolationLevel m_level = IsolationLevel.ReadCommitted;
21
22                 /*
23                  * Constructors
24                  */
25                 
26                 protected OleDbTransaction (OleDbConnection cnc)
27                 {
28                         m_connection = cnc;
29                         libgda.gda_connection_begin_transaction (m_connection.GdaConnection,
30                                                                  null);
31                 }
32
33                 protected OleDbTransaction (OleDbConnection cnc,
34                                             IsolationLevel level) : this (cnc)
35                 {
36                         m_level = level;
37                 }
38
39                 /*
40                  * Properties
41                  */
42
43                 IDbConnection IDbTransaction.Connection
44                 {
45                         get {
46                                 return m_connection;
47                         }
48                 }
49
50                 IsolationLevel IDbTransaction.IsolationLevel
51                 {
52                         get {
53                                 return m_level;
54                         }
55                 }
56
57                 /*
58                  * Methods
59                  */
60
61                 public OleDbTransaction Begin ()
62                 {
63                         return new OleDbTransaction (m_connection);
64                 }
65
66                 public OleDbTransaction Begin (IsolationLevel level)
67                 {
68                         return new OleDbTransaction (m_connection, level);
69                 }
70
71                 void IDbTransaction.Commit ()
72                 {
73                         if (!libgda.gda_connection_commit_transaction (
74                                     m_connection.GdaConnection,
75                                     null))
76                                 throw new InvalidOperationException ();
77                 }
78
79                 void IDbTransaction.Rollback ()
80                 {
81                         if (!libgda.gda_connection_rollback_transaction (
82                                     m_connection.GdaConnection,
83                                     null))
84                                 throw new InvalidOperationException ();
85                 }
86
87                 [MonoTODO]
88                 void IDisposable.Dispose ()
89                 {
90                         throw new NotImplementedException ();
91                 }
92         }
93 }