Skip to content

SqlBatchCommand support CommandBehavior#4125

Open
campersau wants to merge 2 commits intodotnet:mainfrom
campersau:GetColumnSchemaKeyInfo
Open

SqlBatchCommand support CommandBehavior#4125
campersau wants to merge 2 commits intodotnet:mainfrom
campersau:GetColumnSchemaKeyInfo

Conversation

@campersau
Copy link
Copy Markdown

@campersau campersau commented Apr 1, 2026

Description

#1825 added the Batch APIs and also added a CommandBehavior property to SqlBatchCommand which was completly unused.
Note: SqlBatchCommand.CommandBehavior is a custom property in SqlClient which isn't in the DbBatchCommand

Also the CommandBehavior for ExecuteReader was ignored.

This PR enables the use of the SqlBatchCommand.CommandBehavior and also supports passing CommandBehavior to ExecuteReader.

Issues

Fixes #4083

Testing

Added tests for passing CommandBehavior.SchemaOnly | CommandBehavior.KeyInfo to SqlBatchCommand.CommandBehavior.
Added tests for passing CommandBehavior.CloseConnection to ExecuteReader.

@campersau campersau requested a review from a team as a code owner April 1, 2026 12:12
@github-project-automation github-project-automation bot moved this to To triage in SqlClient Board Apr 1, 2026
_batchCommand.SetBatchRPCModeReadyToExecute();
}

internal static void ValidateCommandBehavior(string method, CommandBehavior behavior)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Copied from

internal void ValidateCommandBehavior(string method, CommandBehavior behavior)
{
if (0 != (behavior & ~(CommandBehavior.SequentialAccess | CommandBehavior.CloseConnection)))
{
ADP.ValidateCommandBehavior(behavior);
throw ADP.NotSupportedCommandBehavior(behavior & ~(CommandBehavior.SequentialAccess | CommandBehavior.CloseConnection), method);
}
}

@mdaigle mdaigle moved this from To triage to In review in SqlClient Board Apr 1, 2026
@mdaigle mdaigle added this to the 7.1.0-preview1 milestone Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

SqlBatchCommand.CommandBehavior is unused

2 participants