private void SaveBatch(CursorBatch <TDocument> batch) { var documents = batch.Documents; _count += documents.Count; if (_limit > 0 && _count > _limit.Value) { var remove = _count - _limit.Value; var take = documents.Count - remove; documents = documents.Take(take).ToList(); _count = _limit.Value; } _currentBatch = documents; _cursorId = batch.CursorId; }
private void SaveBatch(CursorBatch <TDocument> batch) { var documents = batch.Documents; _count += documents.Count; if (_limit > 0 && _count > _limit.Value) { var remove = _count - _limit.Value; var take = documents.Count - remove; documents = documents.Take(take).ToList(); _count = _limit.Value; } _currentBatch = documents; _cursorId = batch.CursorId; _postBatchResumeToken = batch.PostBatchResumeToken; DisposeChannelSourceIfNoLongerNeeded(); }
// private methods private IAsyncCursor <TDocument> CreateCursor(IChannelSourceHandle channelSource, BsonDocument query, CursorBatch <TDocument> batch) { var getMoreChannelSource = new ServerChannelSource(channelSource.Server, channelSource.Session.Fork()); return(new AsyncCursor <TDocument>( getMoreChannelSource, _collectionNamespace, query, batch.Documents, batch.CursorId, _batchSize, _limit < 0 ? Math.Abs(_limit.Value) : _limit, _resultSerializer, _messageEncoderSettings)); }
private AsyncCursor <TDocument> CreateCursor(IChannelSourceHandle channelSource, CursorBatch <TDocument> batch, bool slaveOk) { var getMoreChannelSource = new ServerChannelSource(channelSource.Server); return(new AsyncCursor <TDocument>( getMoreChannelSource, _collectionNamespace, _filter ?? new BsonDocument(), batch.Documents, batch.CursorId, _batchSize, _limit < 0 ? Math.Abs(_limit.Value) : _limit, _resultSerializer, _messageEncoderSettings, _cursorType == CursorType.TailableAwait ? _maxAwaitTime : null)); }
private AsyncCursor <TDocument> CreateCursor(IChannelSourceHandle channelSource, CursorBatch <TDocument> batch, bool slaveOk) { return(new AsyncCursor <TDocument>( channelSource.Fork(), _collectionNamespace, _filter ?? new BsonDocument(), batch.Documents, batch.CursorId, _batchSize, _limit < 0 ? Math.Abs(_limit.Value) : _limit, _resultSerializer, _messageEncoderSettings, null)); // maxTime }