Skip to content

Commit ca3e33d

Browse files
committed
Move Create*Connection methods over
1 parent d49d488 commit ca3e33d

File tree

3 files changed

+180
-168
lines changed

3 files changed

+180
-168
lines changed

src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs

Lines changed: 3 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,8 @@ namespace Microsoft.Data.ProviderBase
1818
{
1919
internal abstract class DbConnectionFactory
2020
{
21-
22-
23-
24-
25-
21+
internal abstract DbConnectionPoolGroupProviderInfo CreateConnectionPoolGroupProviderInfo(
22+
DbConnectionOptions connectionOptions);
2623

2724
internal abstract DbConnectionPoolProviderInfo CreateConnectionPoolProviderInfo(
2825
DbConnectionOptions connectionOptions);
@@ -34,45 +31,7 @@ protected virtual DbMetaDataFactory CreateMetaDataFactory(DbConnectionInternal i
3431
cacheMetaDataFactory = false;
3532
throw ADP.NotSupported();
3633
}
37-
38-
internal DbConnectionInternal CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
39-
{
40-
Debug.Assert(owningConnection != null, "null owningConnection?");
41-
Debug.Assert(poolGroup != null, "null poolGroup?");
42-
43-
DbConnectionOptions connectionOptions = poolGroup.ConnectionOptions;
44-
DbConnectionPoolGroupProviderInfo poolGroupProviderInfo = poolGroup.ProviderInfo;
45-
DbConnectionPoolKey poolKey = poolGroup.PoolKey;
46-
47-
DbConnectionInternal newConnection = CreateConnection(connectionOptions, poolKey, poolGroupProviderInfo, null, owningConnection, userOptions);
48-
if (newConnection != null)
49-
{
50-
SqlClientEventSource.Metrics.HardConnectRequest();
51-
newConnection.MakeNonPooledObject(owningConnection);
52-
}
53-
SqlClientEventSource.Log.TryTraceEvent("<prov.DbConnectionFactory.CreateNonPooledConnection|RES|CPOOL> {0}, Non-pooled database connection created.", ObjectID);
54-
return newConnection;
55-
}
56-
57-
internal DbConnectionInternal CreatePooledConnection(IDbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
58-
{
59-
Debug.Assert(pool != null, "null pool?");
60-
DbConnectionPoolGroupProviderInfo poolGroupProviderInfo = pool.PoolGroup.ProviderInfo;
61-
DbConnectionInternal newConnection = CreateConnection(options, poolKey, poolGroupProviderInfo, pool, owningObject, userOptions);
62-
63-
if (newConnection != null)
64-
{
65-
SqlClientEventSource.Metrics.HardConnectRequest();
66-
67-
newConnection.MakePooledConnection(pool);
68-
}
69-
SqlClientEventSource.Log.TryTraceEvent("<prov.DbConnectionFactory.CreatePooledConnection|RES|CPOOL> {0}, Pooled database connection created.", ObjectID);
70-
return newConnection;
71-
}
72-
73-
internal abstract DbConnectionPoolGroupProviderInfo CreateConnectionPoolGroupProviderInfo(
74-
DbConnectionOptions connectionOptions);
75-
34+
7635
protected DbConnectionOptions FindConnectionOptions(DbConnectionPoolKey key)
7736
{
7837
Debug.Assert(key != null, "key cannot be null");
@@ -568,14 +527,6 @@ internal void QueuePoolGroupForRelease(DbConnectionPoolGroup poolGroup)
568527
SqlClientEventSource.Metrics.ExitActiveConnectionPoolGroup();
569528
}
570529

571-
protected abstract DbConnectionInternal CreateConnection(
572-
DbConnectionOptions options,
573-
DbConnectionPoolKey poolKey,
574-
DbConnectionPoolGroupProviderInfo poolGroupProviderInfo,
575-
IDbConnectionPool pool,
576-
DbConnection owningConnection,
577-
DbConnectionOptions userOptions);
578-
579530
abstract protected DbConnectionOptions CreateConnectionOptions(string connectionString, DbConnectionOptions previous);
580531

581532
abstract protected DbConnectionPoolGroupOptions CreateConnectionPoolGroupOptions(DbConnectionOptions options);

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/WaitHandleDbConnectionPool.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,12 @@ private DbConnectionInternal CreateObject(DbConnection owningObject, DbConnectio
746746

747747
try
748748
{
749-
newObj = _connectionFactory.CreatePooledConnection(this, owningObject, _connectionPoolGroup.ConnectionOptions, _connectionPoolGroup.PoolKey, userOptions);
749+
newObj = _connectionFactory.CreatePooledConnection(
750+
owningObject,
751+
this,
752+
_connectionPoolGroup.PoolKey,
753+
_connectionPoolGroup.ConnectionOptions,
754+
userOptions);
750755
if (newObj == null)
751756
{
752757
throw ADP.InternalError(ADP.InternalErrorCode.CreateObjectReturnedNull); // CreateObject succeeded, but null object

0 commit comments

Comments
 (0)