~ifolder-dev/simias/trunk-packaging

« back to all changes in this revision

Viewing changes to src/core/NU-SqliteProvider/SqliteWrapper/.svn/text-base/SqliteTransaction.cs.svn-base

  • Committer: Jorge O. Castro
  • Date: 2007-12-03 06:56:46 UTC
  • Revision ID: jorge@ubuntu.com-20071203065646-mupcnjcwgm5mnhyt
* Remove a bunch of .svn directories we no longer need.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/****************************************************************************
2
 
 |
3
 
 | Copyright (c) 2007 Novell, Inc.
4
 
 | All Rights Reserved.
5
 
 |
6
 
 | This program is free software; you can redistribute it and/or
7
 
 | modify it under the terms of version 2 of the GNU General Public License as
8
 
 | published by the Free Software Foundation.
9
 
 |
10
 
 | This program is distributed in the hope that it will be useful,
11
 
 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 | GNU General Public License for more details.
14
 
 |
15
 
 | You should have received a copy of the GNU General Public License
16
 
 | along with this program; if not, contact Novell, Inc.
17
 
 |
18
 
 | To contact Novell about this file by physical or electronic mail,
19
 
 | you may find current contact information at www.novell.com 
20
 
 |
21
 
 |  Author: Russ Young
22
 
 |***************************************************************************/
23
 
 
24
 
using System;
25
 
using System.Text;
26
 
using System.Runtime.InteropServices;
27
 
using System.Data;
28
 
 
29
 
namespace Simias.Storage.Provider.Sqlite
30
 
{
31
 
        /// <summary>
32
 
        /// Summary description for SqliteTransaction.
33
 
        /// </summary>
34
 
        public class SqliteTransaction : IDbTransaction
35
 
        {
36
 
                SqliteConnection sqliteConn;
37
 
                SqliteCommand command;
38
 
                IsolationLevel isolationLevel;
39
 
                static string beginTransaction = "BEGIN";
40
 
                static string rollBack = "ROLLBACK";
41
 
                static string commit = "COMMIT";
42
 
 
43
 
                /// <summary>
44
 
                /// 
45
 
                /// </summary>
46
 
                /// <param name="conn"></param>
47
 
                public SqliteTransaction(SqliteConnection conn)
48
 
                {
49
 
                        isolationLevel = IsolationLevel.ReadCommitted;
50
 
                        sqliteConn = conn;
51
 
                        command = conn.CreateCommand();
52
 
                        command.CommandText = beginTransaction;
53
 
                        command.ExecuteNonQuery();
54
 
                }
55
 
 
56
 
                /// <summary>
57
 
                /// 
58
 
                /// </summary>
59
 
                /// <param name="conn"></param>
60
 
                /// <param name="il"></param>
61
 
                public SqliteTransaction(SqliteConnection conn, IsolationLevel il) :
62
 
                        this(conn)
63
 
                {
64
 
                        isolationLevel = il;
65
 
                }
66
 
                
67
 
                #region IDbTransaction Members
68
 
 
69
 
                /// <summary>
70
 
                /// 
71
 
                /// </summary>
72
 
                public void Rollback()
73
 
                {
74
 
                        command.CommandText = rollBack;
75
 
                        command.ExecuteNonQuery();
76
 
                }
77
 
 
78
 
                /// <summary>
79
 
                /// 
80
 
                /// </summary>
81
 
                public void Commit()
82
 
                {
83
 
                        command.CommandText = commit;
84
 
                        command.ExecuteNonQuery();
85
 
                }
86
 
 
87
 
                /// <summary>
88
 
                /// 
89
 
                /// </summary>
90
 
                public IDbConnection Connection
91
 
                {
92
 
                        get
93
 
                        {
94
 
                                return sqliteConn;
95
 
                        }
96
 
                }
97
 
 
98
 
                /// <summary>
99
 
                /// 
100
 
                /// </summary>
101
 
                public System.Data.IsolationLevel IsolationLevel
102
 
                {
103
 
                        get
104
 
                        {
105
 
                                return isolationLevel;
106
 
                        }
107
 
                }
108
 
 
109
 
                #endregion
110
 
 
111
 
                #region IDisposable Members
112
 
 
113
 
                /// <summary>
114
 
                /// 
115
 
                /// </summary>
116
 
                public void Dispose()
117
 
                {
118
 
                        command.Dispose();
119
 
                }
120
 
 
121
 
                #endregion
122
 
        }
123
 
}