Link Search Menu Expand Document

ResultTraceLog


A trace-logging class that holds the reuslt of the trace operation. It derives from TraceLog class.

Properties

Below is the list of properties.

NameDescription
ExecutionTimeHandles the total elapsed time of the actual execution.
ResultHandles the actual execution result.
CancellableTraceLoghandles the actual reference to the associated CancellableTracelog object.

Implementation

Let us say you have a custom trace class named MyCustomTrace. Then, you pass this object when you call the Insert operation.

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

You can set a breakpoint at your MyCustomTrace.AfterExecution() and identify the actual results.

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

By setting the throwException argument to true, an exception will be thrown back to the actual operation.