Skip to content

Conversation

edwardneal
Copy link
Contributor

@edwardneal edwardneal commented Nov 14, 2024

Contributes to #646, adding SqlConnection.GetSchemaAsync.

I can't add the IDbColumnSchemaGenerator method because the .NET Framework version of SqlDataReader doesn't yet implement that interface. #2967 tracks this. SqlDataReader.GetSchemaTableAsync requires some extra work with the state machine to guarantee that the column metadata is available, and I'll submit a separate PR for this.

I've added some basic documentation, but this effectively follows the SqlCommand.[Something]Async pattern of "An asynchronous version of [Something], which <etc.>"

I've also moved the netfx GetSchema methods from SqlConnectionHelper.cs to SqlConnection.cs, to align that part of it with netcore. This contributes to the merge slightly.

@@ -107,7 +109,7 @@ protected virtual void Dispose(bool disposing)
}
}

private DataTable ExecuteCommand(DataRow requestedCollectionRow, string[] restrictions, DbConnection connection)
private async ValueTask<DataTable> ExecuteCommandAsync(DataRow requestedCollectionRow, string[] restrictions, DbConnection connection, bool isAsync, CancellationToken cancellationToken)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice to be seeing proper async/await in SqlClient!

Copy link

codecov bot commented Nov 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.00%. Comparing base (df35633) to head (5f05e45).
Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3005      +/-   ##
==========================================
- Coverage   66.91%   63.00%   -3.91%     
==========================================
  Files         280      273       -7     
  Lines       62386    61987     -399     
==========================================
- Hits        41745    39058    -2687     
- Misses      20641    22929    +2288     
Flag Coverage Δ
addons ?
netcore 67.17% <100.00%> (-1.80%) ⬇️
netfx 62.28% <100.00%> (-6.97%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@edwardneal edwardneal changed the title Implement SqlConnection.GetSchemaAsync Implement SqlConnection.GetSchemaAsync and SqlDataReader.GetSchemaTableAsync Nov 15, 2024
@edwardneal edwardneal marked this pull request as draft November 15, 2024 22:38
This introduces async-over-sync, removing such requires work with the state machine and separate review.
@edwardneal edwardneal marked this pull request as ready for review November 16, 2024 08:56
@edwardneal edwardneal changed the title Implement SqlConnection.GetSchemaAsync and SqlDataReader.GetSchemaTableAsync Implement SqlConnection.GetSchemaAsync Nov 16, 2024
@mdaigle mdaigle added Enhancement 💡 Issues that are feature requests for the drivers we maintain. Public API 🆕 Issues/PRs that introduce new APIs to the driver. labels Nov 25, 2024
@paulmedynski
Copy link
Contributor

@edwardneal - Can you resolve the conflicts, and then I will kick off another CI run?

@edwardneal edwardneal requested a review from a team as a code owner July 2, 2025 21:14
@edwardneal
Copy link
Contributor Author

Thanks @paulmedynski, I've just brought the branch up to date.

@paulmedynski
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

Copy link
Contributor

@paulmedynski paulmedynski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few inconsistencies and questions.

@paulmedynski paulmedynski requested a review from a team July 4, 2025 10:20
Remove SqlDataReader.GetSchemaTableAsync (and references to such.)
Expand test coverage of both GetSchema and GetSchemaAsync.
Correct typo in documentation for GetSchema and GetSchemaAsync.
@paulmedynski
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@paulmedynski paulmedynski requested a review from a team July 11, 2025 19:58
@paulmedynski paulmedynski self-assigned this Aug 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement 💡 Issues that are feature requests for the drivers we maintain. Public API 🆕 Issues/PRs that introduce new APIs to the driver.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants