public void Committed(DbTransaction transaction,
                              DbTransactionInterceptionContext interceptionContext)
        {
            var context = EFProfilerContextProvider.GetLoggedDbTransaction(transaction, interceptionContext);

            _profiler.TransactionCommitted(transaction, context);
        }
        public void RolledBack(DbTransaction transaction,
                               DbTransactionInterceptionContext interceptionContext)
        {
            var context = EFProfilerContextProvider.GetLoggedDbTransaction(transaction, interceptionContext);

            _profiler.TransactionRolledBack(transaction, context);
        }
        public void Closed(DbConnection connection,
                           DbConnectionInterceptionContext interceptionContext)
        {
            var context = EFProfilerContextProvider.GetLoggedDbConnection(connection, interceptionContext);

            _profiler.ConnectionClosed(connection, context);
        }
        public void BeganTransaction(DbConnection connection,
                                     BeginTransactionInterceptionContext interceptionContext)
        {
            var context = EFProfilerContextProvider.GetLoggedDbConnection(connection, interceptionContext);

            _profiler.TransactionBegan(connection, context);
        }
        public void Disposing(DbTransaction transaction,
                              DbTransactionInterceptionContext interceptionContext)
        {
            var context = EFProfilerContextProvider.GetLoggedDbTransaction(transaction, interceptionContext);

            _profiler.TransactionDisposing(transaction, context);
        }
        public void ScalarExecuting(DbCommand command,
                                    DbCommandInterceptionContext <object> interceptionContext)
        {
            var context = EFProfilerContextProvider.GetLoggedDbCommand(command, interceptionContext);

            _profiler.ScalarExecuting(command, context);
            _stopwatch.Restart();
        }
        public void ScalarExecuted(DbCommand command,
                                   DbCommandInterceptionContext <object> interceptionContext)
        {
            _stopwatch.Stop();
            var context = EFProfilerContextProvider.GetLoggedResult(command, interceptionContext, _stopwatch.ElapsedMilliseconds, null);

            _profiler.ScalarExecuted(command, context);
        }
        public void ReaderExecuting(DbCommand command,
                                    DbCommandInterceptionContext <DbDataReader> interceptionContext)
        {
            var context = EFProfilerContextProvider.GetLoggedDbCommand(command, interceptionContext);

            _profiler.ReaderExecuting(command, context);
            _stopwatch.Restart();
        }
        public void NonQueryExecuting(DbCommand command,
                                      DbCommandInterceptionContext <int> interceptionContext)
        {
            var context = EFProfilerContextProvider.GetLoggedDbCommand(command, interceptionContext);

            _profiler.NonQueryExecuting(command, context);
            _stopwatch.Restart();
        }
        public void ReaderExecuted(DbCommand command,
                                   DbCommandInterceptionContext <DbDataReader> interceptionContext)
        {
            _stopwatch.Stop();

            DataTable dataTable = null;

            if (interceptionContext.OriginalException == null)
            {
                var dataSet = new DataSet {
                    EnforceConstraints = false
                };
                dataTable = new DataTable(tableName: Guid.NewGuid().ToString());
                dataSet.Tables.Add(dataTable);
                dataSet.Load(interceptionContext.OriginalResult, LoadOption.OverwriteChanges, dataTable);

                interceptionContext.Result = dataTable.CreateDataReader();
            }

            var context = EFProfilerContextProvider.GetLoggedResult(command, interceptionContext, _stopwatch.ElapsedMilliseconds, dataTable);

            _profiler.ReaderExecuted(command, context);
        }