diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs index d97a5aa2bd..0cc8e27a7a 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs @@ -9689,6 +9689,8 @@ internal Task TdsExecuteRPC(SqlCommand cmd, _SqlRPC[] rpcArray, int timeout, boo // Stream out parameters SqlParameter[] parameters = rpcext.parameters; + + bool isAdvancedTraceOn = SqlClientEventSource.Log.IsAdvancedTraceOn(); for (int i = (ii == startRpc) ? startParam : 0; i < parameters.Length; i++) { @@ -9723,7 +9725,7 @@ internal Task TdsExecuteRPC(SqlCommand cmd, _SqlRPC[] rpcArray, int timeout, boo if (mt.IsNewKatmaiType) { - WriteSmiParameter(param, i, 0 != (rpcext.paramoptions[i] & TdsEnums.RPC_PARAM_DEFAULT), stateObj); + WriteSmiParameter(param, i, 0 != (rpcext.paramoptions[i] & TdsEnums.RPC_PARAM_DEFAULT), stateObj, isAdvancedTraceOn); continue; } @@ -10456,7 +10458,7 @@ private void WriteParameterName(string parameterName, TdsParserStateObject state } private static readonly IEnumerable __tvpEmptyValue = new List().AsReadOnly(); - private void WriteSmiParameter(SqlParameter param, int paramIndex, bool sendDefault, TdsParserStateObject stateObj) + private void WriteSmiParameter(SqlParameter param, int paramIndex, bool sendDefault, TdsParserStateObject stateObj, bool advancedTraceIsOn) { // // Determine Metadata @@ -10508,7 +10510,10 @@ private void WriteSmiParameter(SqlParameter param, int paramIndex, bool sendDefa } var sendDefaultValue = sendDefault ? 1 : 0; - SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, Sending parameter '{1}', default flag={2}, metadata:{3}", ObjectID, param.ParameterName, sendDefaultValue, metaData.TraceString(3)); + if (advancedTraceIsOn) + { + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, Sending parameter '{1}', default flag={2}, metadata:{3}", ObjectID, param.ParameterName, sendDefaultValue, metaData.TraceString(3)); + } // // Write parameter metadata