Link Search Menu Expand Document

ResultTraceLog


A trace-logging class that holds the result of a trace operation. It derives from TraceLog and is passed to all AfterExecution methods of the ITrace object.

Properties

NameDescription
ExecutionTimeThe total elapsed time of the operation.
ResultThe result of the operation.
CancellableTraceLogA reference to the associated CancellableTracelog object.

Implementation

Pass a custom trace object when calling an operation such as Insert.

using (var connection = new SqlConnection(connectionString))
{
    connection.Insert<Person>(person, trace: new MyCustomTrace());
}

In the AfterExecution() method, inspect the trace results.

public void AfterExecution<TResult>(ResultTraceLog<TResult> log)
{
    Console.WriteLine($"AfterExecution: {log.Statement}, TotalTime: {log.ExecutionTime.TotalSeconds} second(s)");
}

Setting the throwException argument to true causes an exception to be thrown back to the caller.