Skip to content

Conversation

benrr101
Copy link
Contributor

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:

  • ExecuteScalar
  • ExecuteScalarAsync
  • ExecuteScalarBatchAsync
  • ExecuteScalarUntilEndAsync
  • InternalExecuteScalarAsync (renamed to ExecuteScalarAsyncInternal)
  • CompleteExecuteScalar

Issues

Continuing work on #1261

Testing

Projects continue to build, and SqlCommandTests pass locally. CI will complete the validation.

@benrr101 benrr101 added this to the 7.0-preview2 milestone Sep 17, 2025
@benrr101 benrr101 added the Common Project 🚮 Things that relate to the common project project label Sep 17, 2025
@benrr101 benrr101 requested a review from a team as a code owner September 17, 2025 23:31
@Copilot Copilot AI review requested due to automatic review settings September 17, 2025 23:31
Copy link
Contributor

@Copilot 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 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

* Restore comment re: async untyped value getter
* Flip order of correlation event and trace event
* Introduce netfx style of result, success, return
Copy link

codecov bot commented Sep 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.68%. Comparing base (e472245) to head (4e703f6).
⚠️ Report is 5 commits behind head on main.

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     
Flag Coverage Δ
addons 90.82% <ø> (ø)
netcore 68.10% <100.00%> (-5.19%) ⬇️
netfx 68.80% <95.15%> (+2.30%) ⬆️

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.

@mdaigle mdaigle self-assigned this Sep 22, 2025
@samsharma2700 samsharma2700 self-requested a review September 23, 2025 17:08
@benrr101 benrr101 merged commit 37d8a3f into main Sep 23, 2025
252 checks passed
@benrr101 benrr101 deleted the dev/russellben/merge/sqlcommand-nocer-scalar branch September 23, 2025 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Common Project 🚮 Things that relate to the common project project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants