Class that describes the arguemnts to a query trace event.
Inheritance: System.EventArgs
示例#1
0
 private static void BeginQuery(object sender, QueryTraceEventArgs e)
 {
     var store = Store;
     var metadata = MakeMetadata(e);
     store.List.Enqueue(metadata);
     store.Dictionary.TryAdd(e.Token, metadata);
     metadata.Stopwatch.Start();
 }
示例#2
0
 /// <summary>
 /// Invokes the query end event.
 /// </summary>
 /// <param name="e">The <see cref="Passive.Diagnostics.QueryTraceEventArgs"/> instance containing the event data.</param>
 internal static void InvokeQueryEnd(QueryTraceEventArgs e)
 {
     var handler = QueryEnd;
     if (handler != null)
     {
         handler(null, e);
     }
 }
示例#3
0
        /// <summary>
        /// Invokes the query end event.
        /// </summary>
        /// <param name="e">The <see cref="Passive.Diagnostics.QueryTraceEventArgs"/> instance containing the event data.</param>
        internal static void InvokeQueryEnd(QueryTraceEventArgs e)
        {
            var handler = QueryEnd;

            if (handler != null)
            {
                handler(null, e);
            }
        }
示例#4
0
 private static GlimpsePassiveMetadata MakeMetadata(QueryTraceEventArgs e)
 {
     return new GlimpsePassiveMetadata
                {
                    Sql = e.Sql,
                    Arguments = e.Arguments.ToArray(),
                    Context = e.Context,
                    Stopwatch = new Stopwatch()
                };
 }
示例#5
0
        /// <summary>
        ///   Returns a single result
        /// </summary>
        public object Scalar(DynamicCommand command)
        {
            var queryTraceEventArgs = new QueryTraceEventArgs(command.Sql, command.Arguments, command.Context);
            QueryTrace.InvokeQueryBegin(queryTraceEventArgs);

            using (var conn = this.OpenConnection())
            {
                var scalar = this.CreateDbCommand(command, connection: conn).ExecuteScalar();
                QueryTrace.InvokeQueryEnd(queryTraceEventArgs);
                return scalar;
            }
        }
示例#6
0
 /// <summary>
 ///   Enumerates the reader yielding the results
 /// </summary>
 public IEnumerable<object> Query(DynamicCommand command)
 {
     var queryTraceEventArgs = new QueryTraceEventArgs(command.Sql, command.Arguments, command.Context);
     QueryTrace.InvokeQueryBegin(queryTraceEventArgs);
     using (var conn = this.OpenConnection())
     {
         var dbCommand = this.CreateDbCommand(command, connection: conn);
         using (var rdr = dbCommand.ExecuteReader(CommandBehavior.CloseConnection))
         {
             QueryTrace.InvokeQueryEnd(queryTraceEventArgs);
             while (rdr.Read())
             {
                 var d = (IDictionary<string, object>) new ExpandoObject();
                 for (var i = 0; i < rdr.FieldCount; i++)
                 {
                     var value = rdr[i];
                     d.Add(rdr.GetName(i), DBNull.Value.Equals(value) ? null : value);
                 }
                 yield return d;
             }
         }
     }
 }
示例#7
0
 private static void EndQuery(object sender, QueryTraceEventArgs e)
 {
     var metadata = Store.Dictionary[e.Token];
     metadata.Stopwatch.Stop();
 }