예제 #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);
            }