public override InterceptionResult <DbDataReader> ReaderExecuting(DbCommand command, CommandEventData eventData, InterceptionResult <DbDataReader> result) { if (Core.Configuration.AuditDisabled || ExcludeReaderEvents) { return(result); } var auditEvent = new AuditEventCommandEntityFramework { CommandEvent = CreateEvent(command, eventData) }; _currentScope = CreateAuditScope(auditEvent); return(result); }
private async Task <IAuditScope> CreateAuditScopeAsync(AuditEventCommandEntityFramework cmdEvent) { var eventType = AuditEventType? .Replace("{database}", cmdEvent.CommandEvent.Database) .Replace("{method}", cmdEvent.CommandEvent.Method.ToString()); var factory = Core.Configuration.AuditScopeFactory; var options = new AuditScopeOptions() { EventType = eventType, AuditEvent = cmdEvent, SkipExtraFrames = 3 }; return(await factory.CreateAsync(options)); }
public async override ValueTask <InterceptionResult <DbDataReader> > ReaderExecutingAsync(DbCommand command, CommandEventData eventData, InterceptionResult <DbDataReader> result, CancellationToken cancellationToken = default) #endif { if (Core.Configuration.AuditDisabled || ExcludeReaderEvents) { return(await base.ReaderExecutingAsync(command, eventData, result, cancellationToken)); } var auditEvent = new AuditEventCommandEntityFramework { CommandEvent = CreateEvent(command, eventData) }; _currentScope = await CreateAuditScopeAsync(auditEvent); return(await base.ReaderExecutingAsync(command, eventData, result, cancellationToken)); }