Table of Contents

Struct DbCommandDiagnoser<TCommand, TArgs>

Namespace
LfrlAnvil.Sql.Internal
Assembly
LfrlAnvil.Sql.Core.dll

Represents an object capable of diagnosing SQL statements invoked through IDbCommand instances.

public readonly struct DbCommandDiagnoser<TCommand, TArgs> where TCommand : IDbCommand

Type Parameters

TCommand

IDbCommand type.

TArgs

Delegate argument type.

Inherited Members

Constructors

DbCommandDiagnoser(Action<TCommand, TArgs>?, Action<TCommand, TArgs, TimeSpan, Exception?>?)

Creates a new DbCommandDiagnoser<TCommand, TArgs> instance.

public DbCommandDiagnoser(Action<TCommand, TArgs>? beforeExecute = null, Action<TCommand, TArgs, TimeSpan, Exception?>? afterExecute = null)

Parameters

beforeExecute Action<TCommand, TArgs>

Optional delegate invoked just before an SQL statement execution starts.

afterExecute Action<TCommand, TArgs, TimeSpan, Exception>

Optional delegate invoked just after an SQL statement execution has finished.

Properties

AfterExecute

Optional delegate invoked just after an SQL statement execution has finished.

public Action<TCommand, TArgs, TimeSpan, Exception?>? AfterExecute { get; }

Property Value

Action<TCommand, TArgs, TimeSpan, Exception>

BeforeExecute

Optional delegate invoked just before an SQL statement execution starts.

public Action<TCommand, TArgs>? BeforeExecute { get; }

Property Value

Action<TCommand, TArgs>

Methods

ExecuteAsync<TResult>(TCommand, TArgs, Func<TCommand, Task<TResult>>)

Executes provided IDbCommand asynchronously.

public ValueTask<TResult> ExecuteAsync<TResult>(TCommand command, TArgs args, Func<TCommand, Task<TResult>> invoker)

Parameters

command TCommand

Command to execute.

args TArgs

BeforeExecute/AfterExecute delegate arguments.

invoker Func<TCommand, Task<TResult>>

Delegate that invokes the provided command and returns the result.

Returns

ValueTask<TResult>

ValueTask<TResult> that returns the result of the invocation.

Type Parameters

TResult

Result type.

ExecuteAsync<TResult>(TCommand, TArgs, Func<TCommand, ValueTask<TResult>>)

Executes provided IDbCommand asynchronously.

public ValueTask<TResult> ExecuteAsync<TResult>(TCommand command, TArgs args, Func<TCommand, ValueTask<TResult>> invoker)

Parameters

command TCommand

Command to execute.

args TArgs

BeforeExecute/AfterExecute delegate arguments.

invoker Func<TCommand, ValueTask<TResult>>

Delegate that invokes the provided command and returns the result.

Returns

ValueTask<TResult>

ValueTask<TResult> that returns the result of the invocation.

Type Parameters

TResult

Result type.

Execute<TResult>(TCommand, TArgs, Func<TCommand, TResult>)

Executes provided IDbCommand synchronously.

public TResult Execute<TResult>(TCommand command, TArgs args, Func<TCommand, TResult> invoker)

Parameters

command TCommand

Command to execute.

args TArgs

BeforeExecute/AfterExecute delegate arguments.

invoker Func<TCommand, TResult>

Delegate that invokes the provided command and returns the result.

Returns

TResult

Result of the invocation.

Type Parameters

TResult

Result type.