[CSHARP-1681] Count maxing out at 1000 Created: 31/May/16  Updated: 05/Apr/19  Resolved: 26/Oct/16

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Minor - P4
Reporter: Morgan Abel Assignee: Unassigned
Resolution: Done Votes: 0
Labels: question
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Here is the example code:

IMongoCollection<T> collection = _database.GetCollection<T>(name);
return Convert.ToInt32(await collection.CountAsync(filter, new CountOptions()

{ Limit = 99999999}

));

With a blank filter there are thousands of documents in the collection. Running collection.count() directly on the console returns the correct number. Running this code against the same exact collection and server returns a max of 1000.



 Comments   
Comment by Craig Wilson [ 01/Jun/16 ]

Hi Morgan,

I can't reproduce what you are saying. I used the following code to recreate the problem, but don't have any issues.

using System;
using System.Collections.Generic;
using MongoDB.Bson;
using MongoDB.Driver;
 
namespace TestBugs
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var client = new MongoClient();
            var db = client.GetDatabase("test");
            var c = db.GetCollection<BsonDocument>("awesome");
            c.DeleteMany("{}");
            var docs = new List<BsonDocument>();
            for (int i = 0; i < 10000; i++)
            {
                docs.Add(new BsonDocument("_id", i));
            }
            c.InsertMany(docs);
 
            var filter = Builders<BsonDocument>.Filter.Gt("_id", 20);
            Console.WriteLine(c.Count(filter));
            Console.WriteLine(c.CountAsync(filter).Result);
        }
    }
}

If you are still having issues, I'll need a simple program with which to reproduce the problem.

Craig

Generated at Wed Feb 07 21:40:22 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.