Repository navigation
ExpressiveCommand reads a procedure's parameter names asynchronously - #302
Merged
Merged
Conversation
…onously An asynchronous run of a stored procedure on a command made over an IDbConnection that is a DbConnection looked the parameter names up with the blocking GetSchema call, on the async thread and without observing the cancellation token. ExpressiveCommand now overrides the asynchronous GetProcedureParameterNamesAsync as ExpressiveDbCommand does, so the lookup uses GetSchemaAsync on net10.0 and net11.0 (the netstandard targets keep the synchronous lookup, as before). Cost: first use of a procedure per connection only, nothing per call or row. Not user-visible beyond not blocking, so no release-notes line. Tests: an ExpressiveCommand over a DbConnection held as IDbConnection records GetSchemaAsync on the async path and GetSchema on the sync path. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ames # Conflicts: # Source/Core/PublicAPI.Unshipped.txt
…more The override's summary now says the lookup is asynchronous on net10.0 and later (GetSchemaAsync) and synchronous on the netstandard targets. Its header and inheritdoc are wrapped to about 80 columns. Tests: the synchronous run is written one call per line; an asynchronous lookup over a connection that is not a DbConnection gives no names and touches nothing; the caller's cancellation token reaches GetSchemaAsync. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…inly The cancellation token of the asynchronous names lookup can cancel it only on net10.0 and later; on the netstandard targets it is checked before the synchronous lookup starts, and the call blocks the thread and returns a completed task. Say so in the override's documentation, and document the OperationCanceledException. A test comment no longer claims what the default GetSchemaAsync does. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An
ExpressiveCommand(a command made over anIDbConnection) that runs a stored procedure asynchronously read the procedure's parameter names with a blockingGetSchemacall on the calling thread.ExpressiveDbCommandalready overrides the asynchronous method and usesGetSchemaAsync;ExpressiveCommandoverrode only the synchronous one, so the base class's default wrapped the blocking call.The change
ExpressiveCommandoverridesGetProcedureParameterNamesAsyncthe wayExpressiveDbCommanddoes: when the connection is aDbConnectionit callsProcedureSchemaNames.GetAsync; any other connection has no names. The lookup is asynchronous on net10.0 and later (GetSchemaAsync, with the caller's token). The netstandard targets have no such method: there the lookup is still synchronous, as before, and the token is only checked before it starts. The documentation says so per target. The override is added to the unshipped public API list. No release note: the behavior only differs in not blocking the thread on net10.0 and later.Cost
Once per procedure and connection, when the names are first read: the same single schema read as before, now asynchronous on net10.0 and later. A call whose names are already known pays nothing.
Tests
Four in
ProcedureSchemaNamesTests, over a fakeDbConnectionbehind anIDbConnection: the asynchronous run reads the names withGetSchemaAsync(with the override reverted this test failed withExpected: 1, Actual: 0on the asynchronous call count), the synchronous run still usesGetSchema, the asynchronous lookup over a connection that is not aDbConnectiongives no names, and the caller's token reachesGetSchemaAsync.Reviews
A three-lens review (correctness and tests, the repository's written rules, documentation accuracy) found no defect in the change. Applied: the netstandard wording, the
OperationCanceledExceptiondocumentation, a test comment. Not applied: the asynchronous-path test asserts the asynchronous call count only (a stronger assertion would need a fake that does not call the base), and the non-DbConnectiontest passes without the override because the base default gives the same answer; both are noted as limits, the first test fails without the override.Checks: Release and Debug tests pass, 0 build warnings, 267 sample checks, VS MSBuild 0 errors,
dotnet formatstyle and analyzers clean on all 28 checks, DocFX 0 warnings, the style scan clean.🤖 Generated with Claude Code