MongoDb NORM - 分页和总文档
使用 MongoDb NORM 驱动程序,有谁知道是否可以将光标定位到类似于下面的“查询”集合,以便可以检索文档的“页面”以及查询文档的总数?
> var j = db.People.find().skip(2).limit(2)
> j.count()
13
> j
{ "_id" : NumberLong(25), "Name" : "Ted" }
{ "_id" : NumberLong(26), "Name" : "Tom" }
因为我假设以下执行 MongoDbquery 两次......
totalItems = peopleCollection.Count(queryExpando);
peopleList = peopleCollection.Find(queryExpando, orderByExpando, pageSize, startIndex).ToList();
Using the MongoDb NORM driver, does anyone know whether it's possible to get the cursor to a 'queried' collection similar to below, so that a 'page' of documents can be retrieved as well as the total number of queried documents?
> var j = db.People.find().skip(2).limit(2)
> j.count()
13
> j
{ "_id" : NumberLong(25), "Name" : "Ted" }
{ "_id" : NumberLong(26), "Name" : "Tom" }
As I assume that the following performs the MongoDbquery twice...
totalItems = peopleCollection.Count(queryExpando);
peopleList = peopleCollection.Find(queryExpando, orderByExpando, pageSize, startIndex).ToList();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定是否还有其他方法,但您可能可以使用 LINQ 来完成您需要的操作:
I am not sure if there is another way, but you can probably use LINQ to do what you need: