Linq 未检索大表中的正确项目

发布于 2024-07-26 01:08:57 字数 610 浏览 2 评论 0原文

我遇到了一个非常奇怪的问题。

我有一个包含超过 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

晨光如昨 2024-08-02 01:08:57

也许这可能会做到这一点:

Dim Items = From Item In DB.Items _
        Where Item.CatID = CatID _
        Order By Item.PubDate _
        Select Item Take 100

由于您按 Item.PubDate 降序 排序,因此我删除了降序,以便您可以从 Item.PubDate 的最早记录中获取前 100 条记录。代码>Item.PubDate 字段。

Perhaps this might do it:

Dim Items = From Item In DB.Items _
        Where Item.CatID = CatID _
        Order By Item.PubDate _
        Select Item Take 100

Since you were ordering by Item.PubDate Descending I removed the Descending so that you would take the first 100 records from the earliest records respective of the Item.PubDate field.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文