Beispiel #1
0
 /// <summary>
 /// get number of all documents in collection
 /// </summary>
 /// <param name="options">count options</param>
 /// <returns>returns the count of all documents in a collection or view with count options.</returns>
 public Task <long> EstimatedCountAsync(EstimatedDocumentCountOptions options)
 {
     return(Retry(() =>
     {
         return Collection.EstimatedDocumentCountAsync(options);
     }));
 }
 public UnifiedEstimatedDocumentCountOperation(
     IMongoCollection <BsonDocument> collection,
     EstimatedDocumentCountOptions options)
 {
     _collection = collection;
     _options    = options;
 }
Beispiel #3
0
 /// <summary>
 /// get number of all documents in collection
 /// </summary>
 /// <param name="options">count options</param>
 /// <returns>returns the count of all documents in a collection or view with count options.</returns>
 public long EstimatedCount(EstimatedDocumentCountOptions options)
 {
     return(Retry(() =>
     {
         return Collection.EstimatedDocumentCount(options);
     }));
 }
Beispiel #4
0
        public UnifiedEstimatedDocumentCountOperation Build(string targetCollectionId, BsonDocument arguments)
        {
            var collection = _entityMap.GetCollection(targetCollectionId);

            var options = new EstimatedDocumentCountOptions();

            foreach (var argument in arguments ?? Enumerable.Empty <BsonElement>())
            {
                switch (argument.Name)
                {
                case "comment":
                    options.Comment = argument.Value.AsBsonValue;
                    break;

                case "maxTimeMS":
                    options.MaxTime = TimeSpan.FromMilliseconds(argument.Value.AsInt32);
                    break;

                default:
                    throw new FormatException($"Invalid {nameof(UnifiedEstimatedDocumentCountOperation)} argument name: '{argument.Name}'.");
                }
            }

            return(new UnifiedEstimatedDocumentCountOperation(collection, options));
        }
Beispiel #5
0
        public void constructor_should_initialize_instance()
        {
            var result = new EstimatedDocumentCountOptions();

            result.Comment.Should().BeNull();
            result.MaxTime.Should().NotHaveValue();
        }
Beispiel #6
0
        public void MaxTime_set_should_have_expected_result(
            [Values(null, 1, 2)] int?maxTimeSeconds)
        {
            var value   = maxTimeSeconds.HasValue ? (TimeSpan?)TimeSpan.FromSeconds(maxTimeSeconds.Value) : null;
            var subject = new EstimatedDocumentCountOptions();

            subject.MaxTime = value;

            subject.MaxTime.Should().Be(value);
        }
Beispiel #7
0
 public Task <long> EstimatedDocumentCountAsync(EstimatedDocumentCountOptions options = null, CancellationToken cancellationToken = default)
 {
     throw new NotImplementedException();
 }
Beispiel #8
0
 /// <inheritdoc/>
 public long EstimatedDocumentCount(EstimatedDocumentCountOptions options = null, CancellationToken cancellationToken = default)
 {
     throw new System.NotImplementedException();
 }
 public async Task <long> EstimatedDocumentCountAsync(EstimatedDocumentCountOptions options = null, CancellationToken cancellationToken = new CancellationToken()) =>
 await _semaphore.AddRequest(_base.EstimatedDocumentCountAsync(options, cancellationToken));
Beispiel #10
0
 public Task <long> EstimatedDocumentCountAsync(EstimatedDocumentCountOptions options = null, CancellationToken cancellationToken = default)
 {
     return(Task.FromResult(EstimatedDocumentCount(options, cancellationToken)));
 }
Beispiel #11
0
 public long EstimatedDocumentCount(EstimatedDocumentCountOptions options = null, CancellationToken cancellationToken = default)
 {
     return(docs.Count);
 }
Beispiel #12
0
 /// <inheritdoc/>
 public Task <long> EstimatedDocumentCountAsync(EstimatedDocumentCountOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(_actualCollection.EstimatedDocumentCountAsync(options, cancellationToken));
 }
 public long EstimatedDocumentCount(EstimatedDocumentCountOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(collection.EstimatedDocumentCount(options, cancellationToken));
 }
Beispiel #14
0
 public virtual Task <long> EstimatedDocumentCountAsync(EstimatedDocumentCountOptions options = null, CancellationToken cancellationToken = new CancellationToken()) => throw new NotImplementedException();