Exemplo n.º 1
0
 private static object AddParameterToCommand(IDataAccessCommand command, SqlTraceParameter parameter,
                                             object paramValue)
 {
     if (parameter.CallToString && paramValue != null)
     {
         paramValue = paramValue.ToString();
     }
     command.AddParameter(parameter.Name, paramValue);
     return(paramValue);
 }
Exemplo n.º 2
0
        /// <summary>
        /// This method must be overriden and forms the core logging method called by all other TraceEvent methods.
        /// </summary>
        /// <param name="eventCache">A cache of data that defines the trace event</param>
        /// <param name="source">The trace source</param>
        /// <param name="eventType">The type of event</param>
        /// <param name="id">The unique ID of the trace event</param>
        /// <param name="message">A message to be output regarding the trace event</param>
        protected override void TraceEventCore(TraceEventCache eventCache, string source, TraceEventType eventType,
                                               int id, string message)
        {
            using (IDataAccessCommand command = DataAccessAdapter.CreateCommand())
            {
                foreach (SqlTraceParameter parameter in Parameters)
                {
                    object paramValue = null;
                    bool   gotValue   =
                        parameter.PropertyReader.TryGetValue(out paramValue, eventCache, source, eventType, id, message,
                                                             null);
                    AddParameterToCommand(command, parameter, gotValue ? paramValue : null);
                }

                command.Execute();
            }
        }
Exemplo n.º 3
0
 private static object AddParameterToCommand(IDataAccessCommand command, SqlTraceParameter parameter,
                                             object paramValue)
 {
     if (parameter.CallToString && paramValue != null)
     {
         paramValue = paramValue.ToString();
     }
     command.AddParameter(parameter.Name, paramValue);
     return paramValue;
 }