Skip to content

Use using declaration for paramsCmd#4010

Open
SimonCropp wants to merge 1 commit intodotnet:mainfrom
SimonCropp:Use-using-declaration-for-paramsCmd
Open

Use using declaration for paramsCmd#4010
SimonCropp wants to merge 1 commit intodotnet:mainfrom
SimonCropp:Use-using-declaration-for-paramsCmd

Conversation

@SimonCropp
Copy link
Contributor

Change local SqlCommand instantiation to a using declaration so paramsCmd is disposed automatically.

Change local SqlCommand instantiation to a using declaration so paramsCmd is disposed automatically. This ensures the command is disposed at the end of the scope and prevents potential resource leaks while preserving the CommandType = StoredProcedure initialization.
Copilot AI review requested due to automatic review settings March 6, 2026 12:32
@SimonCropp SimonCropp requested a review from a team as a code owner March 6, 2026 12:32
@github-project-automation github-project-automation bot moved this to To triage in SqlClient Board Mar 6, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves resource management in SqlCommand.DeriveParameters() by ensuring a locally-created SqlCommand used for parameter discovery is disposed deterministically.

Changes:

  • Converted the local paramsCmd instantiation to a C# using declaration so it is disposed automatically at the end of the method scope.

@paulmedynski paulmedynski added the Code Health 💊 Issues/PRs that are targeted to source code quality improvements. label Mar 9, 2026
@paulmedynski paulmedynski modified the milestones: 7.0.1, 7.1.0-preview1 Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Code Health 💊 Issues/PRs that are targeted to source code quality improvements.

Projects

Status: To triage

Development

Successfully merging this pull request may close these issues.

3 participants