數據庫連接池Data Connection Framework具備Connection pooling機制
連接池企業應用組件圖如下
主要文件代碼
/// <summary>
/// 連接池上下文
/// </summary>
public sealed class ConnectionPoolContext : IDisposable
{
/// <summary>
/// 池對象工廠
/// </summary>
private PoolObjectFactory _factory;
/// <summary>
/// 默認連接字符
/// </summary>
private string _defaultConnectionString;
/// <summary>
/// 工廠名稱
/// </summary>
private string _factoryName;
/// <summary>
/// 類型
/// </summary>
private Type _factoryType;
/// <summary>
/// SQL狀態倉庫
/// </summary>
private SqlStatementRepository _statementRepository;
/// <summary>
/// 連接池
/// </summary>
private static Dictionary<string
/// <summary>
/// 默認連接字符屬性
/// </summary>
public string DefaultConnectionString
{
get
{
return _defaultConnectionString;
}
set
{
_defaultConnectionString = value;
}
}
/// <summary>
/// 工廠名
/// </summary>
public string FactoryName
{
get
{
return _factoryName;
}
set
{
_factoryName = value;
}
}
/// <summary>
/// SQL狀態倉庫屬性
/// </summary>
public SqlStatementRepository StatementRepository
{
get
{
if (_statementRepository == null)
_statementRepository = new SqlStatementRepository();
return _statementRepository;
}
}
/// <summary>
/// 對象工廠模式
/// </summary>
internal PoolObjectFactory Factory
{
get
{
return _factory;
}
set
{
_factory = value;
}
}
/// <summary>
/// 實例化一個連接池
/// </summary>
/// <param name=
/// <returns></returns>
public static ConnectionPoolContext Instance(string id)
{
From:http://tw.wingwit.com/Article/program/net/201311/13457.html