System.Data.SqlClient.SqlClientDiagnosticListenerExtensions.WriteCommandBefore C# (CSharp) Method

WriteCommandBefore() public static method

public static WriteCommandBefore ( this @this, SqlCommand sqlCommand, [ operation = "" ) : Guid
@this this
sqlCommand SqlCommand
operation [
return Guid
        public static Guid WriteCommandBefore(this DiagnosticListener @this, SqlCommand sqlCommand, [CallerMemberName] string operation = "")
        {
            if (@this.IsEnabled(SqlBeforeExecuteCommand))
            {
                Guid operationId = Guid.NewGuid();

                @this.Write(
                    SqlBeforeExecuteCommand,
                    new
                    {
                        OperationId = operationId,
                        Operation = operation,
                        ConnectionId = sqlCommand.Connection?.ClientConnectionId,
                        Command = sqlCommand
                    });

                return operationId;
            }
            else
                return Guid.Empty;
        }