Exemple #1
0
        public IEnumerator <T> GetEnumerator()
        {
            var attempt = Interlocked.Increment(ref _readAttempts);

            if (attempt > 1)
            {
                throw DataReaderException.ResultSetReadMoreThanOnce();
            }
            if ((_context != null && _context.IsCompleted) || _reader.Reader.IsClosed)
            {
                throw DataReaderException.ReaderClosed();
            }
            return(new ResultSetEnumerator(_results, _reader, _context, _map, _currentSet));
        }
Exemple #2
0
        public IAsyncEnumerator <T> GetAsyncEnumerator(CancellationToken cancellationToken = new CancellationToken())
        {
            var attempt = Interlocked.Increment(ref _readAttempts);

            if (attempt > 1)
            {
                throw DataReaderException.ResultSetReadMoreThanOnce();
            }
            if (_context?.IsCompleted == true || _reader.Reader.IsClosed)
            {
                throw DataReaderException.ReaderClosed();
            }
            return(new ResultSetEnumerator(_results, _reader, _context, _map, _currentSet));
        }