Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -271,22 +271,9 @@ internal SqlMetaDataFactory GetMetaDataFactory(
{
Debug.Assert(poolGroup is not null, "connectionPoolGroup may not be null.");

// Get the matadatafactory from the pool entry. If it does not already have one
// Get the metadata factory from the pool entry. If it does not already have one
// create one and save it on the pool entry
SqlMetaDataFactory metaDataFactory = poolGroup.MetaDataFactory;

// CONSIDER: serializing this so we don't construct multiple metadata factories
// if two threads happen to hit this at the same time. One will be GC'd
if (metaDataFactory is null)
{
metaDataFactory = CreateMetaDataFactory(internalConnection, out bool allowCache);
if (allowCache)
{
poolGroup.MetaDataFactory = metaDataFactory;
}
}

return metaDataFactory;
return poolGroup.MetaDataFactory ??= CreateMetaDataFactory(internalConnection);
}

internal void QueuePoolForRelease(IDbConnectionPool pool, bool clearing)
Expand Down Expand Up @@ -756,16 +743,13 @@ private static DbConnectionPoolGroupOptions CreateConnectionPoolGroupOptions(Sql
return poolingOptions;
}

private static SqlMetaDataFactory CreateMetaDataFactory(
DbConnectionInternal internalConnection,
out bool cacheMetaDataFactory)
private static SqlMetaDataFactory CreateMetaDataFactory(DbConnectionInternal internalConnection)
{
Debug.Assert(internalConnection is not null, "internalConnection may not be null.");

Stream xmlStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Microsoft.Data.SqlClient.SqlMetaData.xml");
Debug.Assert(xmlStream is not null, $"{nameof(xmlStream)} may not be null.");

cacheMetaDataFactory = true;
return new SqlMetaDataFactory(xmlStream,
internalConnection.ServerVersion,
internalConnection.ServerVersion);
Expand Down