Table of Contents

Interface IQueryInterceptor

Namespace
NextORM.Core
Assembly
nextorm.core.dll

Observes the lifecycle of the commands a context executes. The events are raised by the context's execution axis, not by the command: a DbCommand is only the event payload and cannot log or profile itself.

public interface IQueryInterceptor
Extension Methods

Remarks

Register implementations with DataContextBuilder.AddInterceptor (applies to every context the builder creates) or DataContext.AddInterceptor (per context instance). Interceptors are invoked in registration order and must be thread-safe, since a context may execute concurrently. A command created for a cached query plan is reused across executions, so implementations must not change CommandText.

Methods

CommandExecuted(CommandEventData, DbCommand, TimeSpan)

Called after the command has executed successfully.

void CommandExecuted(CommandEventData eventData, DbCommand command, TimeSpan elapsed)

Parameters

eventData CommandEventData

Metadata about the command.

command DbCommand

The command that executed.

elapsed TimeSpan

The time spent executing the command.

CommandExecuting(CommandEventData, DbCommand)

Called immediately before the command is executed.

void CommandExecuting(CommandEventData eventData, DbCommand command)

Parameters

eventData CommandEventData

Metadata about the command.

command DbCommand

The command about to execute.

CommandFailed(CommandEventData, DbCommand, Exception)

Called when executing the command throws.

void CommandFailed(CommandEventData eventData, DbCommand command, Exception exception)

Parameters

eventData CommandEventData

Metadata about the command.

command DbCommand

The command that failed.

exception Exception

The exception thrown by the provider.

CommandInitialized(CommandEventData, DbCommand)

Called when a command has been created and its parameters bound. For a query it is raised once, by the planning axis, when the plan is built (a cache hit does not raise it again); for a DML statement it is raised on every execution, because mutation commands are not cached.

void CommandInitialized(CommandEventData eventData, DbCommand command)

Parameters

eventData CommandEventData

Metadata about the command.

command DbCommand

The command that was created.