Table of Contents

Class EventDefinition<TParam1, TParam2, TParam3, TParam4, TParam5>

Namespace
Microsoft.EntityFrameworkCore.Diagnostics
Assembly
Microsoft.EntityFrameworkCore.dll

Defines metadata for an event with three parameters and a cached delegate to log the event with reduced allocations.

public class EventDefinition<TParam1, TParam2, TParam3, TParam4, TParam5> : EventDefinitionBase

Type Parameters

TParam1
TParam2
TParam3
TParam4
TParam5
Inheritance
EventDefinition<TParam1, TParam2, TParam3, TParam4, TParam5>
Inherited Members

Remarks

See Implementation of database providers and extensions for more information and examples.

Constructors

EventDefinition(ILoggingOptions, EventId, LogLevel, string, Func<LogLevel, Action<ILogger, TParam1, TParam2, TParam3, TParam4, TParam5, Exception?>>)

Creates an event definition instance.

public EventDefinition(ILoggingOptions loggingOptions, EventId eventId, LogLevel level, string eventIdCode, Func<LogLevel, Action<ILogger, TParam1, TParam2, TParam3, TParam4, TParam5, Exception?>> logActionFunc)

Parameters

loggingOptions ILoggingOptions

Logging options.

eventId EventId

The EventId.

level LogLevel

The LogLevel at which the event will be logged.

eventIdCode string

A string representing the code that should be passed to ConfigureWarnings(Action<WarningsConfigurationBuilder>).

logActionFunc Func<LogLevel, Action<ILogger, TParam1, TParam2, TParam3, TParam4, TParam5, Exception>>

Function to create a cached delegate for logging the event.

Methods

GenerateMessage(TParam1, TParam2, TParam3, TParam4, TParam5)

Generates the message that would be logged without logging it. Typically used for throwing an exception in warning-as-error cases.

public virtual string GenerateMessage(TParam1 arg1, TParam2 arg2, TParam3 arg3, TParam4 arg4, TParam5 arg5)

Parameters

arg1 TParam1

The first message argument.

arg2 TParam2

The second message argument.

arg3 TParam3

The third message argument.

arg4 TParam4

The fourth message argument.

arg5 TParam5

The fifth message argument.

Returns

string

The message string.

Log<TLoggerCategory>(IDiagnosticsLogger<TLoggerCategory>, TParam1, TParam2, TParam3, TParam4, TParam5)

Logs the event, or throws if the event has been configured to be treated as an error.

public virtual void Log<TLoggerCategory>(IDiagnosticsLogger<TLoggerCategory> logger, TParam1 arg1, TParam2 arg2, TParam3 arg3, TParam4 arg4, TParam5 arg5) where TLoggerCategory : LoggerCategory<TLoggerCategory>, new()

Parameters

logger IDiagnosticsLogger<TLoggerCategory>

The logger to which the event should be logged.

arg1 TParam1

The first message argument.

arg2 TParam2

The second message argument.

arg3 TParam3

The third message argument.

arg4 TParam4

The fourth message argument.

arg5 TParam5

The fifth message argument.

Type Parameters

TLoggerCategory

The DbLoggerCategory.