Class QueryMessage
- Namespace
- MongoDB.Driver.Core.WireProtocol.Messages
- Assembly
- MongoDB.Driver.Core.dll
Represents a Query message.
public class QueryMessage : RequestMessage, IEncodableMessage
- Inheritance
-
QueryMessage
- Implements
- Inherited Members
Constructors
QueryMessage(int, CollectionNamespace, BsonDocument, BsonDocument, IElementNameValidator, int, int, bool, bool, bool, bool, bool, bool, Func<bool>)
Initializes a new instance of the QueryMessage class.
[Obsolete("Use a constructor that does not have an oplogReplay parameter instead.")]
public QueryMessage(int requestId, CollectionNamespace collectionNamespace, BsonDocument query, BsonDocument fields, IElementNameValidator queryValidator, int skip, int batchSize, bool secondaryOk, bool partialOk, bool noCursorTimeout, bool oplogReplay, bool tailableCursor, bool awaitData, Func<bool> shouldBeSent = null)
Parameters
requestIdintThe request identifier.
collectionNamespaceCollectionNamespaceThe collection namespace.
queryBsonDocumentThe query.
fieldsBsonDocumentThe fields.
queryValidatorIElementNameValidatorThe query validator.
skipintThe number of documents to skip.
batchSizeintThe size of a batch.
secondaryOkboolif set to
trueit is OK if the server is not the primary.partialOkboolif set to
truethe server is allowed to return partial results if any shards are unavailable.noCursorTimeoutboolif set to
truethe server should not timeout the cursor.oplogReplayboolif set to
truethe OplogReplay bit will be set.tailableCursorboolif set to
truethe query should return a tailable cursor.awaitDataboolif set to
truethe server should await data (used with tailable cursors).shouldBeSentFunc<bool>A delegate that determines whether this message should be sent.
QueryMessage(int, CollectionNamespace, BsonDocument, BsonDocument, IElementNameValidator, int, int, bool, bool, bool, bool, bool, Func<bool>)
Initializes a new instance of the QueryMessage class.
public QueryMessage(int requestId, CollectionNamespace collectionNamespace, BsonDocument query, BsonDocument fields, IElementNameValidator queryValidator, int skip, int batchSize, bool secondaryOk, bool partialOk, bool noCursorTimeout, bool tailableCursor, bool awaitData, Func<bool> shouldBeSent = null)
Parameters
requestIdintThe request identifier.
collectionNamespaceCollectionNamespaceThe collection namespace.
queryBsonDocumentThe query.
fieldsBsonDocumentThe fields.
queryValidatorIElementNameValidatorThe query validator.
skipintThe number of documents to skip.
batchSizeintThe size of a batch.
secondaryOkboolif set to
trueit is OK if the server is not the primary.partialOkboolif set to
truethe server is allowed to return partial results if any shards are unavailable.noCursorTimeoutboolif set to
truethe server should not timeout the cursor.tailableCursorboolif set to
truethe query should return a tailable cursor.awaitDataboolif set to
truethe server should await data (used with tailable cursors).shouldBeSentFunc<bool>A delegate that determines whether this message should be sent.
Properties
AwaitData
Gets a value indicating whether the server should await data (used with tailable cursors).
public bool AwaitData { get; }
Property Value
BatchSize
Gets the size of a batch.
public int BatchSize { get; }
Property Value
CollectionNamespace
Gets the collection namespace.
public CollectionNamespace CollectionNamespace { get; }
Property Value
Fields
Gets the fields.
public BsonDocument Fields { get; }
Property Value
MessageType
Gets the type of the message.
public override MongoDBMessageType MessageType { get; }
Property Value
NoCursorTimeout
Gets a value indicating whether the server should not timeout the cursor.
public bool NoCursorTimeout { get; }
Property Value
OplogReplay
Gets a value indicating whether the OplogReplay bit will be set.
[Obsolete("OplogReplay is ignored by server versions 4.4.0 and newer.")]
public bool OplogReplay { get; }
Property Value
- bool
trueif the OplogReplay bit will be set; otherwise,false.
PartialOk
Gets a value indicating whether the server is allowed to return partial results if any shards are unavailable.
public bool PartialOk { get; }
Property Value
PostWriteAction
Gets or sets the delegate called to after the message has been written by the encoder.
public Action<IMessageEncoderPostProcessor> PostWriteAction { get; set; }
Property Value
- Action<IMessageEncoderPostProcessor>
The post write delegate.
Query
Gets the query.
public BsonDocument Query { get; }
Property Value
QueryValidator
Gets the query validator.
public IElementNameValidator QueryValidator { get; }
Property Value
ResponseHandling
Gets or sets the response handling.
public CommandResponseHandling ResponseHandling { get; set; }
Property Value
- CommandResponseHandling
The response handling.
SecondaryOk
Gets a value indicating whether it is OK if the server is not the primary.
public bool SecondaryOk { get; }
Property Value
Skip
Gets the number of documents to skip.
public int Skip { get; }
Property Value
TailableCursor
Gets a value indicating whether the query should return a tailable cursor.
public bool TailableCursor { get; }
Property Value
Methods
GetEncoder(IMessageEncoderFactory)
Gets an encoder for the message from an encoder factory.
public override IMessageEncoder GetEncoder(IMessageEncoderFactory encoderFactory)
Parameters
encoderFactoryIMessageEncoderFactoryThe encoder factory.
Returns
- IMessageEncoder
A message encoder.