예제 #1
0
        public override object ExecuteScalar()
        {
            object result  = null;
            var    context = NHProfilerContextProvider.GetLoggedDbCommand(InternalCommand, null);

            _profiler.ScalarExecuting(InternalCommand, context);
            _stopwatch.Restart();
            try
            {
                result = InternalCommand.ExecuteScalar();
            }
            catch (Exception e)
            {
                context = NHProfilerContextProvider.GetLoggedDbCommand(InternalCommand, e);
                _profiler.ScalarExecuting(InternalCommand, context);
                throw;
            }
            finally
            {
                _stopwatch.Stop();
                context = NHProfilerContextProvider.GetLoggedResult(InternalCommand, null, result, _stopwatch.ElapsedMilliseconds, null);
                _profiler.ScalarExecuted(InternalCommand, context);
            }

            return(result);
        }
예제 #2
0
        public void ScalarExecuted(DbCommand command,
                                   DbCommandInterceptionContext <object> interceptionContext)
        {
            _stopwatch.Stop();
            var context = EFProfilerContextProvider.GetLoggedResult(command, interceptionContext, _stopwatch.ElapsedMilliseconds, null);

            _profiler.ScalarExecuted(command, context);
        }