private void ExecuteReader(AsyncDataAdapterCommand asyncDataAdapterCommand, IDbCommand command)
    {
        _resultWriter.BeforeExecuteReader(asyncDataAdapterCommand);
        IDataReader dataReader = null;

        try
        {
            dataReader = command.ExecuteReader();
            var fieldCount = dataReader.FieldCount;
            _resultWriter.AfterExecuteReader(fieldCount);
            var tableIndex = 0;

            while (!_thread.IsStopRequested)
            {
                if (fieldCount > 0)
                {
                    var schemaTable = dataReader.GetSchemaTable();
                    if (schemaTable != null)
                    {
                        Log.Trace("schemaTable:\r\n{0}", schemaTable.ToStringTableString());
                        if (asyncDataAdapterCommand.Query != null)
                        {
                            Parser.ParseResult(asyncDataAdapterCommand.Query.Results[tableIndex], out var name, out var fieldName);
                            schemaTable.TableName = name;
                        }
                    }

                    ReadTable(dataReader, schemaTable, tableIndex);
                }

                if (_rowCount >= _maxRecords || !dataReader.NextResult())
                {
                    break;
                }

                tableIndex++;
            }
        }
        finally
        {
            if (dataReader != null)
            {
                dataReader.Close();
                var recordsAffected = dataReader.RecordsAffected;
                _resultWriter.AfterCloseReader(recordsAffected);
            }
        }
    }
Beispiel #2
0
 void IResultWriter.BeforeExecuteReader(AsyncDataAdapterCommand asyncDataAdapterCommand) => _logResultWriter.BeforeExecuteReader(asyncDataAdapterCommand);
Beispiel #3
0
 void IResultWriter.BeforeExecuteReader(AsyncDataAdapterCommand command)
 {
     _logResultWriter.BeforeExecuteReader(command);
 }