Exemple #1
0
            public async Task <bool> MoveNext(CancellationToken cancellationToken)
            {
                if (_queryRunner == null)
                {
                    _queryRunner = _dataContext.GetQueryRunner(_query, _queryNumber, _expression, _ps);

                    _mapper.QueryRunner = _queryRunner;

                    _dataReader = await _queryRunner.ExecuteReaderAsync(cancellationToken);

                    var skip = _skipAction?.Invoke(_expression, _ps) ?? 0;

                    while (skip-- > 0)
                    {
                        if (!await _dataReader.ReadAsync(cancellationToken))
                        {
                            return(false);
                        }
                    }

                    _take = _takeAction?.Invoke(_expression, _ps) ?? int.MaxValue;
                }

                if (_take-- > 0 && await _dataReader.ReadAsync(cancellationToken))
                {
                    _queryRunner.RowsCount++;

                    Current = _mapper.Map(_queryRunner, _dataReader.DataReader);

                    return(true);
                }

                return(false);
            }
Exemple #2
0
            public async ValueTask <bool> MoveNextAsync()
            {
                if (_context.IsCompleted || _reader.Reader.IsClosed)
                {
                    Current = default;
                    return(false);
                }
                if (_results.CurrentSet != _set)
                {
                    Current = default;
                    return(false);
                }

                var ok = await _reader.ReadAsync(new CancellationToken()).ConfigureAwait(false);

                Current = ok ? _map(_reader.Reader) : default;
                return(ok);
            }