forked from ThatRendle/Simple.Data
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDelegatingConnectionBase1.cs
More file actions
155 lines (140 loc) · 5.84 KB
/
DelegatingConnectionBase1.cs
File metadata and controls
155 lines (140 loc) · 5.84 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
using System.Data;
using System.Data.Common;
namespace Simple.Data.Ado
{
/// <summary>
/// Provides a base class for implementing <see cref="IDbConnection"/> which delegates all the interface methods
/// to a wrapped instance of <see cref="IDbConnection"/>.
/// Also implements the <see cref="DbConnection.GetSchema(string,string[])"/> method which is on <see cref="DbConnection"/> but not <see cref="IDbConnection"/>.
/// </summary>
public abstract class DelegatingConnectionBase : IDbConnection, ISchemaGetter
{
private readonly IDbConnection _delegatedConnection;
/// <summary>
/// Initializes a new instance of the <see cref="DelegatingConnectionBase"/> class.
/// </summary>
/// <param name="delegatedConnection">The connection to which method calls are delegated by default.</param>
protected DelegatingConnectionBase(IDbConnection delegatedConnection)
{
_delegatedConnection = delegatedConnection;
}
protected IDbConnection DelegatedConnection
{
get { return _delegatedConnection; }
}
/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
/// <filterpriority>2</filterpriority>
public virtual void Dispose()
{
_delegatedConnection.Dispose();
}
/// <summary>
/// Begins a database transaction.
/// </summary>
/// <returns>
/// An object representing the new transaction.
/// </returns>
/// <filterpriority>2</filterpriority>
public virtual IDbTransaction BeginTransaction()
{
return _delegatedConnection.BeginTransaction();
}
/// <summary>
/// Begins a database transaction with the specified <see cref="T:System.Data.IsolationLevel"/> value.
/// </summary>
/// <returns>
/// An object representing the new transaction.
/// </returns>
/// <param name="il">One of the <see cref="T:System.Data.IsolationLevel"/> values. </param><filterpriority>2</filterpriority>
public virtual IDbTransaction BeginTransaction(IsolationLevel il)
{
return _delegatedConnection.BeginTransaction(il);
}
/// <summary>
/// Closes the connection to the database.
/// </summary>
/// <filterpriority>2</filterpriority>
public virtual void Close()
{
_delegatedConnection.Close();
}
/// <summary>
/// Changes the current database for an open Connection object.
/// </summary>
/// <param name="databaseName">The name of the database to use in place of the current database. </param><filterpriority>2</filterpriority>
public virtual void ChangeDatabase(string databaseName)
{
_delegatedConnection.ChangeDatabase(databaseName);
}
/// <summary>
/// Creates and returns a Command object associated with the connection.
/// </summary>
/// <returns>
/// A Command object associated with the connection.
/// </returns>
/// <filterpriority>2</filterpriority>
public virtual IDbCommand CreateCommand()
{
return _delegatedConnection.CreateCommand();
}
/// <summary>
/// Opens a database connection with the settings specified by the ConnectionString property of the provider-specific Connection object.
/// </summary>
/// <filterpriority>2</filterpriority>
public virtual void Open()
{
_delegatedConnection.OpenIfClosed();
}
/// <summary>
/// Gets or sets the string used to open a database.
/// </summary>
/// <returns>
/// A string containing connection settings.
/// </returns>
/// <filterpriority>2</filterpriority>
public virtual string ConnectionString
{
get { return _delegatedConnection.ConnectionString; }
set { _delegatedConnection.ConnectionString = value; }
}
/// <summary>
/// Gets the time to wait while trying to establish a connection before terminating the attempt and generating an error.
/// </summary>
/// <returns>
/// The time (in seconds) to wait for a connection to open. The default value is 15 seconds.
/// </returns>
/// <filterpriority>2</filterpriority>
public virtual int ConnectionTimeout
{
get { return _delegatedConnection.ConnectionTimeout; }
}
/// <summary>
/// Gets the name of the current database or the database to be used after a connection is opened.
/// </summary>
/// <returns>
/// The name of the current database or the name of the database to be used once a connection is open. The default value is an empty string.
/// </returns>
/// <filterpriority>2</filterpriority>
public virtual string Database
{
get { return _delegatedConnection.Database; }
}
/// <summary>
/// Gets the current state of the connection.
/// </summary>
/// <returns>
/// One of the <see cref="T:System.Data.ConnectionState"/> values.
/// </returns>
/// <filterpriority>2</filterpriority>
public virtual ConnectionState State
{
get { return _delegatedConnection.State; }
}
public virtual DataTable GetSchema(string collectionName, params string[] constraints)
{
return _delegatedConnection.GetSchema(collectionName, constraints);
}
}
}