使用Mongo dB的DataGrid分页 [英] DataGrid Pagination using Mongo dB
问题描述
我有一个wpf应用程序和mongo db作为后端,如果我从wpf应用程序调用mongo db的查询,它会给我一百万条记录,所以目前我使用的是常规分页,例如将db中的所有数据存储到数据表中并进行分页.但是,如果系统内存不足,则不可能存储那么多记录,因此有人对我说mongo db提供了分页功能,这意味着当用户单击下一个或上一个时,我们可以直接从db调用记录,因此任何人都可以帮助我做到这一点. /p>
I've a wpf app and mongo db as back end, if i call a query to mongo db from wpf app it giving me million of records so currently i'm using normal pagination like storing all data from db into data table and doing pagination. But if system having less memory its impossible to store that much of records, so some body says to me that mongo db provides pagination means we can call records directly from db when user clicks next or previous so any one help me to do this.
推荐答案
You can use mongodb's limit() and skip() to implement paging. For example, to get the 3rd page where page size is 10, you'd use this query:
db.your_collection.find().skip(20).limit(10)
这篇关于使用Mongo dB的DataGrid分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!