internal static void Write(TextWriter stream, CommandBuiltEventArgs e) { if (stream == null) { Debug.WriteLine("Command Text: " + e.Command.CommandText); #if !WINDOWS_UWP && !NETSTANDARD1_3 Debug.Indent(); #endif foreach (DbParameter parameter in e.Command.Parameters) { var valueText = (parameter.Value == null || parameter.Value == DBNull.Value) ? "<NULL>" : parameter.Value.ToString(); Debug.WriteLine($"Parameter: {parameter.ParameterName} = {valueText}"); } #if !WINDOWS_UWP && !NETSTANDARD1_3 Debug.Unindent(); #endif } else { stream.WriteLine("Command Text: " + e.Command.CommandText); foreach (DbParameter parameter in e.Command.Parameters) { var valueText = (parameter.Value == null || parameter.Value == DBNull.Value) ? "<NULL>" : parameter.Value.ToString(); stream.WriteLine($" Parameter: {parameter.ParameterName} = {valueText}"); } } }
/// <summary> /// Override this if you want to examine or modify the DBCommand before it is executed. /// </summary> /// <param name="e">The <see cref="CommandBuiltEventArgs" /> instance containing the event data.</param> protected override void OnCommandBuilt(CommandBuiltEventArgs e) { if (e == null) { throw new ArgumentNullException("e", "e is null."); } e.Command.CommandTimeout = (int)m_Timeout.TotalSeconds; }
/// <summary> /// Override this if you want to examine or modify the DBCommand before it is executed. /// </summary> /// <param name="e">The <see cref="CommandBuiltEventArgs" /> instance containing the event data.</param> protected override void OnCommandBuilt(CommandBuiltEventArgs e) { if (m_Stream == null) { Debug.WriteLine("Command Text: " + e.Command.CommandText); Debug.Indent(); foreach (var parameter in e.Command.Parameters.Enumerate()) { var valueText = (parameter.Value == null || parameter.Value == DBNull.Value) ? "<NULL>" : parameter.Value.ToString(); Debug.WriteLine($"Parameter: {parameter.ParameterName} = {valueText}"); } Debug.Unindent(); } else { m_Stream.WriteLine("Command Text: " + e.Command.CommandText); foreach (var parameter in e.Command.Parameters.Enumerate()) { var valueText = (parameter.Value == null || parameter.Value == DBNull.Value) ? "<NULL>" : parameter.Value.ToString(); m_Stream.WriteLine($" Parameter: {parameter.ParameterName} = {valueText}"); } } }
/// <summary> /// Override this if you want to examine or modify the DBCommand before it is executed. /// </summary> /// <param name="e">The <see cref="CommandBuiltEventArgs"/> instance containing the event data.</param> protected virtual void OnCommandBuilt(CommandBuiltEventArgs e) { }
void ExecutionToken_CommandBuilt(object?sender, CommandBuiltEventArgs e) { OnCommandBuilt(e); }
/// <summary> /// Override this if you want to examine or modify the DBCommand before it is executed. /// </summary> /// <param name="e">The <see cref="CommandBuiltEventArgs" /> instance containing the event data.</param> protected override void OnCommandBuilt(CommandBuiltEventArgs e) { Write(m_Stream, e); }