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);
        }
        public void ScalarExecuting(DbCommand command,
                                    DbCommandInterceptionContext <object> interceptionContext)
        {
            var context = EFProfilerContextProvider.GetLoggedDbCommand(command, interceptionContext);

            _profiler.ScalarExecuting(command, context);
            _stopwatch.Restart();
        }