Example #1
0
        public override int ExecuteNonQuery()
        {
            int result = 0;

            var context = NHProfilerContextProvider.GetLoggedDbCommand(InternalCommand, null);

            _profiler.NonQueryExecuting(InternalCommand, context);
            _stopwatch.Restart();
            try
            {
                result       = InternalCommand.ExecuteNonQuery();
                AffectedRows = result;
            }
            catch (Exception e)
            {
                context = NHProfilerContextProvider.GetLoggedDbCommand(InternalCommand, e);
                _profiler.NonQueryExecuting(InternalCommand, context);
                throw;
            }
            finally
            {
                _stopwatch.Stop();
                context = NHProfilerContextProvider.GetLoggedResult(InternalCommand, null, result, _stopwatch.ElapsedMilliseconds, null);
                _profiler.NonQueryExecuted(InternalCommand, context);
            }

            return(result);
        }
        public void NonQueryExecuting(DbCommand command,
                                      DbCommandInterceptionContext <int> interceptionContext)
        {
            var context = EFProfilerContextProvider.GetLoggedDbCommand(command, interceptionContext);

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