从 RavenDB 中检索整个数据集合 [英] Retrieving entire data collection from a RavenDB

查看:40
本文介绍了从 RavenDB 中检索整个数据集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个需求,我需要从 RavenDB 获取整个数据集合 Users 并将检索到的结果集与另一组数据进行比较.此特定集合中有近 4000 条记录.

I have a requirement where I need to fetch the entire data collection Users from RavenDB and compare the retrieved result set with another set of data. There are close to 4000 records in this particular collection.

因为 Raven 默认是安全的,我不断收到 超出每个会话的请求数 或返回最多 128 条记录的异常.

Because Raven is Safe By Default, I keep getting an exception for either Number of requests per session exceeded or it returns the maximum 128 records.

我不想将属性 Session.Advanced.MaxNumberOfRequestsPerSession 设置为更高的值.

I don't want to set the property Session.Advanced.MaxNumberOfRequestsPerSession to a higher value.

我应该使用什么查询来获取所有记录的数量?处理这种情况的理想方法是什么?

What query should I use to get the count of all the records? What is the ideal approach to handle this situation?

推荐答案

您使用分页,一次阅读 1024 项.

You use paging, and read this 1024 items at a time.

int start = 0;
while(true)
{
   var current = session.Query<User>().Take(1024).Skip(start).ToList();
   if(current.Count == 0)
          break;

   start+= current.Count;
   allUsers.AddRange(current);

}

这篇关于从 RavenDB 中检索整个数据集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆