C# driver for MongoDb: how to use limit+count?

后端 未结 2 1764
眼角桃花
眼角桃花 2020-12-31 18:16

From MongoDb documentation: \"On a query using skip() and limit(), count ignores these parameters by default. Use count(true) to have it consider the skip and limit val

2条回答
  •  感情败类
    2020-12-31 18:53

    Use the Size method instead of Count, as that honors Skip and Limit.

    Console.WriteLine(collection.Find(query).SetSkip(0).SetLimit(1).Size());
    

提交回复
热议问题