【发布时间】:2016-10-06 17:25:52
【问题描述】:
我正在尝试在 Mongo 数据库中进行选择 我正在使用这个 DLL
MongoDB.Bson,MongoDB.Driver,MongoDB.Driver.Linq
我的表有超过 55k 行
一段时间后出现此错误
找不到光标
这是我的代码
var client = new MongoClient(connectionString);
var server = client.GetServer();
var database = server.GetDatabase("Database");
var collection = database.GetCollection<DesktopSessions>("desktop_sessions");
var query = (from e in collection.AsQueryable<DesktopSessions>()
where e.created_at > new DateTime(2012, 7, 1)
select e);
foreach (var item in query)
{
string id = item._id.ToString();
}
我该如何解决这个问题?
【问题讨论】:
-
如果先把 new DateTime() 放到一个变量中,再运行查询,效果会更好吗?
-
一些时间是多少时间?您可能会在光标上超时
-
@I3arnon 游标的默认超时为 10 分钟。除非设置了
noTimeout标志。 -
如何更改超时时间?该过程需要10多分钟
-
请注意,这是 10 分钟不活动,因此如果光标正在迭代,它不会超时。它可能有助于添加更多关于循环中发生的事情以及实际时间、迭代行等的具体信息。
标签: c# linq mongodb mongodb-.net-driver