一、环境
windows2012R2+mongdob 3.0X+ mongdb c#driver 2.2.1.6
二、数据分页显示
1.接口
public IQueryable Table
{
get
{ return collection.AsQueryable();
}
}
2.查询
var query = _articleRepository.Table;
query = query.OrderByDescending(b => b.CreatedOnUtc);
var result= query.ToList();
(简化了,实际是排序后分页获取数据)
3.数据量大时出现错误
出现如下错误:
An unhandled exception occurred while processing the request.
MongoCommandException: Command aggregate failed: exception: Sort exceeded memory limit of 104857600 bytes, but did not opt in to external sorting. Aborting operation. Pass allowDiskUse:true to opt in..
在 MongoDB.Driver.Linq.MongoQueryProviderImpl`1.Execute(Expression expression)
4.allowDiskUse:true 不知都在哪设置,求教。