Exemplo n.º 1
0
        // methods
        private CursorBatch <TDocument> ExecuteProtocol(IChannelHandle channel, BsonDocument wrappedQuery, bool slaveOk, CancellationToken cancellationToken)
        {
            var firstBatchSize = QueryHelper.CalculateFirstBatchSize(_limit, _firstBatchSize ?? _batchSize);

            return(channel.Query <TDocument>(
                       _collectionNamespace,
                       wrappedQuery,
                       _projection,
                       NoOpElementNameValidator.Instance,
                       _skip ?? 0,
                       firstBatchSize,
                       slaveOk,
                       _allowPartialResults ?? false,
                       _noCursorTimeout ?? false,
                       _oplogReplay ?? false,
                       _cursorType != CursorType.NonTailable,   // tailable
                       _cursorType == CursorType.TailableAwait, //await data
                       _resultSerializer,
                       _messageEncoderSettings,
                       cancellationToken));
        }
        private IReadOnlyList <BsonDocument> GetFirstBatchUsingQueryMessage(IChannelHandle channel, BsonDocument query, int batchSize, CancellationToken cancellationToken, out long cursorId)
        {
            var result = channel.Query(
                _collectionNamespace,
                query,
                null,  // fields
                NoOpElementNameValidator.Instance,
                0,     // skip
                batchSize,
                false, // slaveOk
                false, // partialOk
                false, // noCursorTimeout
                false, // oplogReplay
                false, // tailableCursor
                false, // awaitData
                BsonDocumentSerializer.Instance,
                _messageEncoderSettings,
                cancellationToken);

            cursorId = result.CursorId;
            return(result.Documents);
        }