Ejemplo n.º 1
0
        public void ResetEventArgs()
        {
            TransactionOpenArgs         = null;
            TransactionPrecommitingArgs = null;
            TransactionCommitingArgs    = null;
            TransactionCommitedArgs     = null;

            TransactionRollbackingArgs = null;
            TransactionRollbackedArgs  = null;

            PersistingArgs = null;
            PersistedArgs  = null;

            ChangesCancelingArgs = null;
            ChangesCanceledArgs  = null;

            EntityCreatedArgs = null;
            EntityRemoving    = null;
            EntityRemoved     = null;

            EntityFieldGettingArgs      = null;
            EntityFieldValueGetArgs     = null;
            EntityFieldValueSettingArgs = null;
            EntityFieldValueSetArgs     = null;

            QueryExecuting = null;
            QueryExecuted  = null;

            DbCommandExecuting = null;
            DbCommandExecuted  = null;
        }
        private void Encount(object sender, DbCommandEventArgs eventArgs)
        {
            var text = eventArgs.Command.CommandText.Substring(0, 30);

            if (text.Contains("SELECT", StringComparison.OrdinalIgnoreCase))
            {
                SelectCount++;
            }
            else if (text.Contains("UPDATE", StringComparison.OrdinalIgnoreCase))
            {
                UpdateCount++;
            }
            else
            {
                throw new ArgumentOutOfRangeException("eventArgs.Command.CommandText");
            }
        }
Ejemplo n.º 3
0
 public virtual void DbCommandExecuted(object sender, DbCommandEventArgs args)
 {
     if (!Enabled)
     {
         return;
     }
     try {
         // count execution time
         if (!cmdExecutingTime.ContainsKey(args.Command.GetHashCode()))
         {
             Write(args.Command, "Cannot calculate execution time - 'executing' event wasn't raised?!");
         }
         else
         {
             DateTime executingTime = cmdExecutingTime[args.Command.GetHashCode()];
             string   cmdTimeMsg    = String.Format("execution time: {0}", DateTime.Now.Subtract(executingTime));
             Write(args.Command, cmdTimeMsg);
         }
     } catch (Exception ex) {
         Trace.Fail("Cannot write SQL command trace: " + ex.Message);
     }
 }
 private void EventsOnDbCommandExecuting(object sender, DbCommandEventArgs dbCommandEventArgs)
 {
     count++;
     Console.WriteLine(dbCommandEventArgs.Command.CommandText);
 }
Ejemplo n.º 5
0
 private void DbCommandExecutedHandler(object sender, DbCommandEventArgs e)
 {
     CountedCommands++;
 }
 private void CaptureCommand(object sender, DbCommandEventArgs eventArgs)
 => commandText = eventArgs.Command.CommandText;
Ejemplo n.º 7
0
 private void DbContext_CommandExecuted(object sender, DbCommandEventArgs e)
 {
 }
Ejemplo n.º 8
0
 private void OnDbCommandExecuted(object sender, DbCommandEventArgs e) => DbCommandExecuted   = e;
Ejemplo n.º 9
0
 private void EventsOnDbCommandExecuting(object sender, DbCommandEventArgs dbCommandEventArgs)
 {
     LogQueryTextToConsole(dbCommandEventArgs.Command);
 }
 private void Encount(object sender, DbCommandEventArgs eventArgs) => Count++;