Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the SqlCommand class by extracting scalar execution methods into a separate partial class file to improve code organization and maintainability. The change moves all ExecuteScalar-related methods from the platform-specific files into a shared partial class.
- Extracts ExecuteScalar methods into a new shared partial class file SqlCommand.Scalar.cs
- Consolidates duplicate scalar execution logic from both .NET Framework and .NET Core implementations
- Removes scalar execution code from platform-specific SqlCommand files
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| SqlCommand.Scalar.cs | New shared partial class containing all scalar execution methods |
| SqlCommand.netfx.cs | Removes ExecuteScalar and related methods (moved to shared partial) |
| SqlCommand.netcore.cs | Removes ExecuteScalar and related methods (moved to shared partial) |
| Microsoft.Data.SqlClient.csproj (netfx) | Adds reference to new shared partial class file |
| Microsoft.Data.SqlClient.csproj (netcore) | Adds reference to new shared partial class file |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Scalar.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Scalar.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Scalar.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Scalar.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Scalar.cs
Show resolved
Hide resolved
edwardneal
reviewed
Sep 18, 2025
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Scalar.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Scalar.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Scalar.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Scalar.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Scalar.cs
Outdated
Show resolved
Hide resolved
* Restore comment re: async untyped value getter * Flip order of correlation event and trace event * Introduce netfx style of result, success, return
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3619 +/- ##
==========================================
- Coverage 68.30% 65.68% -2.63%
==========================================
Files 276 277 +1
Lines 61641 61593 -48
==========================================
- Hits 42105 40455 -1650
- Misses 19536 21138 +1602
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
paulmedynski
requested changes
Sep 22, 2025
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Scalar.cs
Show resolved
Hide resolved
paulmedynski
approved these changes
Sep 22, 2025
mdaigle
approved these changes
Sep 22, 2025
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Scalar.cs
Show resolved
Hide resolved
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.
Description
Welcome to the next installment of SqlCommand merge PRs. This PR addresses merging of ExecuteScalar and related methods. This begins another organizational step of creating separate partial classes for different large blocks of code. This introduces the .Scalar partial that contains methods that only pertain to executing scalars. Code that is shared across types of execution will remain in the main partial, as will all member variables and properties. Without some division like this, the SqlCommand file will be over 10k lines long and become incredibly difficult to navigate. Feel free to propose alternatives.
This PR merges:
Issues
Continuing work on #1261
Testing
Projects continue to build, and SqlCommandTests pass locally. CI will complete the validation.