public static Guid WriteConnectionCloseBefore(this DiagnosticListener @this, SqlConnection sqlConnection, [CallerMemberName] string operation = "")
{
if (@this.IsEnabled(SqlBeforeCloseConnection))
{
Guid operationId = Guid.NewGuid();
@this.Write(
SqlBeforeCloseConnection,
new
{
OperationId = operationId,
Operation = operation,
ConnectionId = sqlConnection.ClientConnectionId,
Connection = sqlConnection,
Statistics = sqlConnection.Statistics?.GetDictionary(),
Timestamp = Stopwatch.GetTimestamp()
});
return operationId;
}
else
return Guid.Empty;
}