public override int ExecuteNonQuery() { var command = GetCommandLog(); using (var scope = new LoggingScope(_Logger, $"{nameof(ExecuteNonQuery)} - {{Command}}", command)) { var result = _WrappedDbCommand.ExecuteNonQuery(); scope.Complete(); return result; } }
protected async override Task<DbDataReader> ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken) { var command = GetCommandLog(); using (var scope = new LoggingScope(_Logger, $"{nameof(ExecuteReader)} - {{Command}}", command)) { var result = await _WrappedDbCommand.ExecuteReaderAsync(behavior, cancellationToken); scope.Complete(); return result; } }
public async override Task<object> ExecuteScalarAsync(CancellationToken cancellationToken) { string command; try { command = GetCommandLog(); } catch (Exception ex) { _Logger.Error(ex, "Error getting command to log"); command = "Error Getting Command"; } using (var scope = new LoggingScope(_Logger, $"{nameof(ExecuteScalar)} - {{Command}}", command)) { var result = await _WrappedDbCommand.ExecuteScalarAsync(cancellationToken); scope.Complete(); return result; } }
protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior) { var command = GetCommandLog(); using (var scope = new LoggingScope(_Logger, $"{nameof(ExecuteReader)} - {{Command}}", command)) { var result = _WrappedDbCommand.ExecuteReader(); scope.Complete(); return result; } }