Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make EnableOptimizedParameterBinding only apply to text mode commands #2417

Merged
merged 1 commit into from May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/snippets/Microsoft.Data.SqlClient/SqlCommand.xml
Expand Up @@ -1385,7 +1385,8 @@ The <xref:Microsoft.Data.SqlClient.SqlCommand.CreateParameter%2A> method is a st
</Dispose>
<EnableOptimizedParameterBinding>
<summary>
Gets or sets a value indicating whether the command object should optimize parameter performance by disabling Output and InputOutput directions when submitting the command to the SQL Server.
Gets or sets a value indicating whether the command object should optimize parameter performance by disabling Output and InputOutput directions when submitting the command to the SQL Server. <br />
This option is only used when the <see cref="P:Microsoft.Data.SqlClient.SqlCommand.CommandType" /> is <see cref="System.Data.CommandType.Text" >Text</see> otherwise it is ignored.
</summary>
<value>
A value indicating whether the command object should optimize parameter performance by disabling Output and InputOuput parameter directions when submitting the command to the SQL Server.
Expand Down
Expand Up @@ -9222,7 +9222,7 @@ internal Task TdsExecuteSQLBatch(string text, int timeout, SqlNotificationReques
int parametersLength = rpcext.userParamCount + rpcext.systemParamCount;

bool isAdvancedTraceOn = SqlClientEventSource.Log.IsAdvancedTraceOn();
bool enableOptimizedParameterBinding = cmd.EnableOptimizedParameterBinding;
bool enableOptimizedParameterBinding = cmd.EnableOptimizedParameterBinding && cmd.CommandType == CommandType.Text;

for (int i = (ii == startRpc) ? startParam : 0; i < parametersLength; i++)
{
Expand Down
Expand Up @@ -10103,7 +10103,7 @@ internal Task TdsExecuteSQLBatch(string text, int timeout, SqlNotificationReques
int parametersLength = rpcext.userParamCount + rpcext.systemParamCount;

bool isAdvancedTraceOn = SqlClientEventSource.Log.IsAdvancedTraceOn();
bool enableOptimizedParameterBinding = cmd.EnableOptimizedParameterBinding;
bool enableOptimizedParameterBinding = cmd.EnableOptimizedParameterBinding && cmd.CommandType == CommandType.Text;

for (int i = (ii == startRpc) ? startParam : 0; i < parametersLength; i++)
{
Expand Down