Пример #1
0
        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);
        }
Пример #2
0
        public override void Close()
        {
            reader.Close();
            context.OnReaderFinished();

            DbTracing.FireReaderFinished(context);
        }
Пример #3
0
        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);
        }