【问题标题】:How do I query for comments in Orchard?如何在 Orchard 中查询评论?
【发布时间】:2012-01-20 03:23:03
【问题描述】:

我正在尝试为 Orchard CMS 构建一个“最新评论”小部件。

我知道我可以直接查询 SQL,但是我可以在 Orchard 中使用 API 来获取整个博客上的最新 cmets(以及每条评论所属的博客文章等)吗?我一直在查看 IContentManager::Query,但我不太清楚如何使用它来获取我想要的信息。

【问题讨论】:

    标签: asp.net orchardcms


    【解决方案1】:

    查看 Orchard.Comments 模块中的 CommentsService。 Orchard.Comments.Services.CommentsService。它真的很接近你的需要。由于服务返回查询,您可以像这样添加一些额外的排序...

    var query = commentsService.GetCommentsForCommentedContent(blogId);
    var comments = query.OrderByDescending(c => c.CommentDateUtc).Slice(10);
    

    类似的东西。

    【讨论】:

      猜你喜欢
      • 2020-09-04
      • 2010-09-20
      • 2022-08-21
      • 1970-01-01
      • 1970-01-01
      • 2010-12-12
      • 2014-08-12
      • 2023-03-26
      • 1970-01-01
      相关资源
      最近更新 更多