forked from ThatRendle/Simple.Data
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdoAdapterTransaction.cs
More file actions
56 lines (48 loc) · 1.46 KB
/
AdoAdapterTransaction.cs
File metadata and controls
56 lines (48 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Text;
namespace Simple.Data.Ado
{
class AdoAdapterTransaction : IAdapterTransaction
{
private readonly string _name;
private readonly IDbTransaction _dbTransaction;
private readonly IDbConnection _dbConnection;
private readonly bool _sharedConnection;
public AdoAdapterTransaction(IDbTransaction dbTransaction, bool sharedConnection = false) : this(dbTransaction, null, sharedConnection)
{
}
public AdoAdapterTransaction(IDbTransaction dbTransaction, string name, bool sharedConnection = false)
{
_name = name;
_dbTransaction = dbTransaction;
_dbConnection = _dbTransaction.Connection;
_sharedConnection = sharedConnection;
}
internal IDbTransaction DbTransaction
{
get { return _dbTransaction; }
}
public void Dispose()
{
_dbTransaction.Dispose();
if (!_sharedConnection)
_dbConnection.Dispose();
}
public void Commit()
{
_dbTransaction.Commit();
}
public void Rollback()
{
_dbTransaction.Rollback();
}
public string Name
{
get { return _name; }
}
}
}