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
| Name | Description |
|---|---|
| ExecutionTime | The total elapsed time of the operation. |
| Result | The result of the operation. |
| CancellableTraceLog | A 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
throwExceptionargument totruecauses an exception to be thrown back to the caller.