32 [Obsolete(
"Use dependency injection",
false)]
34 where C : IDbConnection, new()
36 private static object _lock =
new object();
37 private C _connection;
38 private string _connectionString;
39 private string _label;
85 return GetManager(database, isDatabaseName,
"default");
107#if NETSTANDARD2_0 || NET5_0 || NET6_0
108 throw new NotSupportedException(
"isDatabaseName==true");
110 var connection = ConfigurationManager.ConnectionStrings[database];
111 if (connection ==
null)
114 var conn = ConfigurationManager.ConnectionStrings[database].ConnectionString;
115 if (
string.IsNullOrEmpty(conn))
122 var ctxName = GetContextName(database, label);
148 _connectionString = connectionString;
151 _connection =
new C { ConnectionString = connectionString };
155 private static string GetContextName(
string connectionString,
string label)
157 return "__db:" + label +
"-" + connectionString;
171 private int _refCount;
179 get {
return _refCount; }
182 private void AddRef()
193 _connection.Dispose();
195 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 within the context of a single data port...
void Dispose()
Dispose object, dereferencing or disposing the connection it is managing.
ConnectionManager< C > GetManager(string database, bool isDatabaseName, string label)
Gets the ConnectionManager object for the specified database.
ConnectionManager< C > GetManager(string database, bool isDatabaseName)
Gets the ConnectionManager object for the specified database.
ConnectionManager GetManager(string database)
Gets the ConnectionManager object for the specified database.
ConnectionManager< C > GetManager(string database, string label)
Gets the ConnectionManager object for the specified database.
ConnectionManager< C > GetManager(string database)
Gets the ConnectionManager object for the specified database.
int RefCount
Gets the current reference count for this object.
IDbConnection Connection
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}).