Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit ccc21d0

Browse files
saurabh500stephentoub
authored andcommitted
Provide GetSchema override for DbConnectionClosed (#26951)
* Provide GetSchema override for DbConnectionClosed * Change names * Code review comment
1 parent f3e7e18 commit ccc21d0

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/System.Data.SqlClient/src/System/Data/ProviderBase/DbConnectionClosed.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ public override void EnlistTransaction(Transaction transaction)
5959
throw ADP.ClosedConnectionError();
6060
}
6161

62+
protected internal override DataTable GetSchema(DbConnectionFactory factory, DbConnectionPoolGroup poolGroup, DbConnection outerConnection, string collectionName, string[] restrictions)
63+
=> throw ADP.ClosedConnectionError();
64+
6265
protected override DbReferenceCollection CreateReferenceCollection()
6366
{
6467
throw ADP.ClosedConnectionError();

src/System.Data.SqlClient/tests/FunctionalTests/SqlConnectionBasicTests.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ public void SqlConnectionInvalidParameters()
8080
Assert.Throws<ArgumentException>(() => new SqlConnection("Integrated Security=truee"));
8181
}
8282

83+
[Fact]
84+
public void ClosedConnectionSchemaRetrieval()
85+
{
86+
using (SqlConnection connection = new SqlConnection(string.Empty))
87+
{
88+
Assert.Throws<InvalidOperationException>(() => connection.GetSchema());
89+
}
90+
}
91+
8392
[Fact]
8493
public void ConnectionTimeoutTestWithThread()
8594
{

0 commit comments

Comments
 (0)