コード例 #1
0
        public override Task <IAsyncCursor <BsonDocument> > ListCollectionsAsync(IClientSessionHandle session, ListCollectionsOptions options, CancellationToken cancellationToken)
        {
            Ensure.IsNotNull(session, nameof(session));
            var operation = CreateListCollectionsOperation(options);
            var effectiveReadPreference = ReadPreferenceResolver.GetEffectiveReadPreference(session, null, ReadPreference.Primary);

            return(ExecuteReadOperationAsync(session, operation, effectiveReadPreference, cancellationToken));
        }
コード例 #2
0
        public override async Task <IAsyncCursor <string> > ListCollectionNamesAsync(IClientSessionHandle session, ListCollectionNamesOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            Ensure.IsNotNull(session, nameof(session));
            var operation = CreateListCollectionNamesOperation(options);
            var effectiveReadPreference = ReadPreferenceResolver.GetEffectiveReadPreference(session, null, ReadPreference.Primary);
            var cursor = await ExecuteReadOperationAsync(session, operation, effectiveReadPreference, cancellationToken).ConfigureAwait(false);

            return(new BatchTransformingAsyncCursor <BsonDocument, string>(cursor, ExtractCollectionNames));
        }
コード例 #3
0
        public override Task <TResult> RunCommandAsync <TResult>(IClientSessionHandle session, Command <TResult> command, ReadPreference readPreference = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            Ensure.IsNotNull(session, nameof(session));
            Ensure.IsNotNull(command, nameof(command));

            var operation = CreateRunCommandOperation(command);
            var effectiveReadPreference = ReadPreferenceResolver.GetEffectiveReadPreference(session, readPreference, ReadPreference.Primary);

            return(ExecuteReadOperationAsync(session, operation, effectiveReadPreference, cancellationToken));
        }
コード例 #4
0
        private Task <T> ExecuteReadOperationAsync <T>(IClientSessionHandle session, IReadOperation <T> operation, CancellationToken cancellationToken)
        {
            var readPreference = ReadPreferenceResolver.GetEffectiveReadPreference(session, null, _settings.ReadPreference);

            return(ExecuteReadOperationAsync(session, operation, readPreference, cancellationToken));
        }