CancellableTraceLog
A trace-logging class that is being used to cancel the existing operation. It is used in all BEFORE methods of the ITrace object. It derives from TraceLog class.
Properties
Below is the list of properties.
Name | Description |
---|---|
IsCancelled` | Is used to determine whether the operation has been cancelled. |
IsThrowException | Is used to determine whether an exception will be thrown back to the actual operation. |
Parameter | Handles the parameters of the execution. |
Statement | Handles the actual SQL statement generated by the library. |
Methods
Below is the list of methods.
Name | Description |
---|---|
Cancel | Is used to cancel the actual operation. It accepts the throwException argument to define whether an exception will be thrown back to the operation during cancellation. |
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.BeforeExecution()
method and can call the Cancel()
method to cancel the operation.
public void BeforeExecution(CancellableTraceLog log)
{
if (log.Statement.IndexOf("INSERT") <= 0)
{
log.Cancel(true);
}
}
By setting the
throwException
argument totrue
, an exception will be thrown back to the actual operation.