PetaPoco fetch 仅检索totalCount,但不检索items

发布于 2024-12-02 03:21:16 字数 748 浏览 3 评论 0原文

使用 PetaPoco,我正在运行与此类似的提取:

var result=db.Page<article>(1, 20, // <-- page number and items per page
    "SELECT * FROM articles WHERE category=@0 ORDER BY date_posted DESC", "coolstuff");

其中文章定义为

public class article
{
  public long article_id { get; set; }
  public string title { get; set; }
  public DateTime date_created { get; set; }
  public bool draft { get; set; }
  public string content { get; set; }
}

但是虽然 result.TotalItems 显示正确的数字,但 result.Items 不包含任何内容。我还尝试使用

[PetaPoco.TableName("articles")]
[PetaPoco.PrimaryKey("article_id")]

显式列映射

[PetaPoco.Column]

来装饰类文章的定义,但结果始终相同。有错误还是我做错了什么?

Using PetaPoco, I am running a fetch similar to this:

var result=db.Page<article>(1, 20, // <-- page number and items per page
    "SELECT * FROM articles WHERE category=@0 ORDER BY date_posted DESC", "coolstuff");

where article is defined as

public class article
{
  public long article_id { get; set; }
  public string title { get; set; }
  public DateTime date_created { get; set; }
  public bool draft { get; set; }
  public string content { get; set; }
}

But while result.TotalItems shows the correct number, result.Items does not contain anyting. I have also tried to decorate the definition of class article with

[PetaPoco.TableName("articles")]
[PetaPoco.PrimaryKey("article_id")]

and explicit column mapping

[PetaPoco.Column]

but result has always been the same. Is there a bug or what am I doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

塔塔猫 2024-12-09 03:21:16

确保页码从 1 开始,而不是从 0 开始。您在此处未显示的代码中可能存在该错误。

Make sure that the page number starts from 1 and not 0. Its possible that in your code that you did not show here has that bug.

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