public static void WriteCommandError(this DiagnosticListener @this, Guid operationId, SqlCommand sqlCommand, Exception ex, [CallerMemberName] string operation = "")
{
if (@this.IsEnabled(SqlErrorExecuteCommand))
{
@this.Write(
SqlErrorExecuteCommand,
new
{
OperationId = operationId,
Operation = operation,
ConnectionId = sqlCommand.Connection?.ClientConnectionId,
Command = sqlCommand,
Exception = ex,
Timestamp = Stopwatch.GetTimestamp()
});
}
}