PetaPoco fetch 仅检索totalCount,但不检索items
使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保页码从 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.