2

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

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]

但结果总是一样的。有错误还是我做错了什么?

4

1 回答 1

0

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

于 2015-11-03T02:06:45.980 回答