コード例 #1
0
 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;
     }
 }
コード例 #2
0
 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;
     }
 }
コード例 #3
0
 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;
     }
 }
コード例 #4
0
 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;
     }
 }