public override object ExecuteScalar() { if (!DbTracing.IsEnabled) { return(command.ExecuteScalar()); } var context = new DbTracingContext(DbTracingType.Scalar, connection, command); object result = null; DbTracing.FireCommandExecuting(context); try { context.OnStarted(); result = command.ExecuteScalar(); context.OnFinished(result); } catch (Exception ex) { context.OnFailed(ex); DbTracing.FireCommandFailed(context); throw; } DbTracing.FireCommandFinished(context); return(result); }
protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior) { if (!DbTracing.IsEnabled) { return(command.ExecuteReader(behavior)); } var context = new DbTracingContext(DbTracingType.Reader, connection, command); DbTracing.FireCommandExecuting(context); DbTracingDataReader result = null; try { context.OnStarted(); result = new DbTracingDataReader(command.ExecuteReader(behavior), context); context.OnFinished(result.UnderlyingReader); } catch (Exception ex) { context.OnFailed(ex); DbTracing.FireCommandFailed(context); throw; } DbTracing.FireCommandFinished(context); return(result); }