Linq 未检索大表中的正确项目
我遇到了一个非常奇怪的问题。
我有一个包含超过 800.000 条记录和 2GB mdf 数据库的表。
当我尝试获取最后的记录时:
我只得到一个月前的记录,最后的记录没有出现。
Dim Items = From Item In DB.Items _
Where Item.CatID = CatID _
Order By Item.PubDate Descending _
Select Item Take 100
但如果我将选择限制为最后一个 ID,那么我会得到预期的结果。
Dim Items = From Item In DB.Items _
Where Item.CatID = CatID _
And Item.ID > 600000 _
Order By Item.PubDate Descending _
Select Item Take 100
那么,这是怎么回事。
Linq 对可以查询的记录有限制吗?
I'm with a very strange problem.
I've a table with more than 800.000 records and 2GB mdf Database.
When I try to get the last records:
I'm only getting the records until one month ago, the last ones doesn't show up.
Dim Items = From Item In DB.Items _
Where Item.CatID = CatID _
Order By Item.PubDate Descending _
Select Item Take 100
But if I limit the Select to the last IDs, then I get the expected result.
Dim Items = From Item In DB.Items _
Where Item.CatID = CatID _
And Item.ID > 600000 _
Order By Item.PubDate Descending _
Select Item Take 100
So, what's going on here.
Does Linq have a limit of the records it can query?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许这可能会做到这一点:
由于您按
Item.PubDate 降序
排序,因此我删除了降序
,以便您可以从Item.PubDate
的最早记录中获取前 100 条记录。代码>Item.PubDate 字段。Perhaps this might do it:
Since you were ordering by
Item.PubDate Descending
I removed theDescending
so that you would take the first 100 records from the earliest records respective of theItem.PubDate
field.