private void OnExecuted <TState>( DbCommand command, DbCommandInterceptionContext <TState> interceptionContext, Func <string, DbParameterCollection, DateTime, DateTime, object> specificExecutedAction, Func <string, DbParameterCollection, DateTime, DateTime, object> specificLongTimeExecutedAction, Func <Exception, string, DbParameterCollection, DateTime, DateTime, object> specificErrorAction, string memberName) { InternalLoggingSharedContext.RemoveStartTime(command, out var stamp); var now = DateTime.Now; var ms = 0D; if (stamp != default(DateTime)) { ms = now.Subtract(stamp).TotalMilliseconds; } var contextId = Guid.NewGuid(); if (interceptionContext.Exception != null) { OnError(interceptionContext.Exception, command, contextId, stamp, now, ms, specificErrorAction, memberName); } else if (ms > 1000) { OnLongTimeExecuted(command, contextId, stamp, now, ms, specificLongTimeExecutedAction, memberName); } else { OnExecuted(command, contextId, stamp, now, ms, specificExecutedAction, memberName); } }
private void OnExecuting(DbCommand command, Action <string, DbParameterCollection, DateTime> specificAction) { InternalLoggingSharedContext.AddStartTime(command, out var now); var localAction = _descriptor.ExposeExecutingInterceptor; localAction += specificAction; localAction?.Invoke(command.CommandText, command.Parameters, now); }