1#if !NETFX_CORE && !(ANDROID || IOS)
37 [Obsolete(
"Use dependency injection",
false)]
39 where C : IDbConnection, new()
40 where T : IDbTransaction
42 private static object _lock =
new object();
43 private C _connection;
44 private T _transaction;
45 private string _connectionString;
46 private string _label;
92 return GetManager(database, isDatabaseName,
"default");
114#if NETSTANDARD2_0 || NET5_0 || NET6_0
115 throw new NotSupportedException(
"isDatabaseName==true");
117 var connection = ConfigurationManager.ConnectionStrings[database];
118 if (connection ==
null)
121 var conn = ConfigurationManager.ConnectionStrings[database].ConnectionString;
122 if (
string.IsNullOrEmpty(conn))
130 var contextLabel = GetContextName(database, label);
150 _connectionString = connectionString;
153 _connection =
new C();
154 _connection.ConnectionString = connectionString;
157 _transaction = (T)_connection.BeginTransaction();
161 private static string GetContextName(
string connectionString,
string label)
163 return "__transaction:" + label +
"-" + connectionString;
191 private bool _commit =
false;
206#region Reference counting
208 private int _refCount;
216 get {
return _refCount; }
219 private void AddRef()
234 _transaction.Commit();
236 _transaction.Rollback();
240 _transaction.Dispose();
241 _connection.Dispose();
242 ApplicationContext.
LocalContext.Remove(GetContextName(_connectionString, _label));
Provides consistent context information between the client and server DataPortal objects.
ApplicationContext(ApplicationContextAccessor applicationContextAccessor)
Creates a new instance of the type
ContextDictionary LocalContext
Returns the application-specific context data that is local to the current AppDomain.
Provides an automated way to reuse open database connections and associated ADO.NET transactions with...
void Commit()
Indicates that the current transactional scope has completed successfully.
int RefCount
Gets the current reference count for this object.
TransactionManager< C, T > GetManager(string database, bool isDatabaseName)
Gets the TransactionManager object for the specified database.
TransactionManager< C, T > GetManager(string database, bool isDatabaseName, string label)
Gets the TransactionManager object for the specified database.
T Transaction
Gets a reference to the current ADO.NET transaction object.
TransactionManager< C, T > GetManager(string database, string label)
Gets the TransactionManager object for the specified database.
TransactionManager< C, T > GetManager(string database)
Gets the TransactionManager object for the specified database.
C Connection
Gets a reference to the current ADO.NET connection object that is associated with current trasnaction...
void Dispose()
Dispose object, dereferencing or disposing the connection it is managing.
A strongly-typed resource class, for looking up localized strings, etc.
static string DatabaseNameNotFound
Looks up a localized string similar to Database name not found in config file ({0}).