1
|
|
#region Copyright
|
2
|
|
|
3
|
|
|
4
|
|
|
5
|
|
|
6
|
|
|
7
|
|
|
8
|
|
|
9
|
|
|
10
|
|
|
11
|
|
|
12
|
|
|
13
|
|
|
14
|
|
|
15
|
|
|
16
|
|
|
17
|
|
#endregion
|
18
|
|
|
19
|
|
using System;
|
20
|
|
using System.Data;
|
21
|
|
|
22
|
|
using Seasar.Extension.ADO;
|
23
|
|
using Seasar.Extension.ADO.Impl;
|
24
|
|
|
25
|
|
namespace Seasar.Extension.Tx.Impl
|
26
|
|
{
|
27
|
|
|
28
|
|
|
29
|
|
|
30
|
|
public class TxDataSource : DataSourceImpl, IDataSource
|
31
|
|
{
|
32
|
|
private ITransactionContext context;
|
33
|
|
|
34
|
45
|
public TxDataSource() : base()
|
35
|
|
{
|
36
|
|
}
|
37
|
|
|
38
|
0
|
public TxDataSource(DataProvider provider, string connectionString) : base(provider, connectionString)
|
39
|
|
{
|
40
|
|
}
|
41
|
|
|
42
|
89
|
public new IDbConnection GetConnection()
|
43
|
|
{
|
44
|
89
|
IDbConnection con = null;
|
45
|
89
|
ITransactionContext tc = this.Context.Current;
|
46
|
89
|
if(tc != null && tc.Connection != null)
|
47
|
|
{
|
48
|
40
|
con = tc.Connection;
|
49
|
|
}
|
50
|
|
else
|
51
|
|
{
|
52
|
49
|
con = base.GetConnection();
|
53
|
|
}
|
54
|
89
|
return con;
|
55
|
|
}
|
56
|
|
|
57
|
|
public ITransactionContext Context
|
58
|
|
{
|
59
|
204
|
get
|
60
|
|
{
|
61
|
204
|
return this.context;
|
62
|
|
}
|
63
|
45
|
set
|
64
|
|
{
|
65
|
45
|
this.context = value;
|
66
|
|
}
|
67
|
|
}
|
68
|
|
|
69
|
0
|
public override IDbTransaction GetTransaction()
|
70
|
|
{
|
71
|
|
return this.context.Current.Transaction;
|
72
|
|
}
|
73
|
|
}
|
74
|
|
}
|
75
|
|
|