如何在Orchard中查询评论?

发布于 2024-12-27 18:24:55 字数 169 浏览 3 评论 0原文

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

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

I am trying to build a "Latest Comments" widget for Orchard CMS.

I know I could directly query the SQL, but is there an API I can use in Orchard to get the latest comments on the whole blog (and which blog post each comment belongs to, etc)? I've been looking at IContentManager::Query, but I'm not exactly clear how I can use this to get the information I want.

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

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

发布评论

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

评论(1

南风几经秋 2025-01-03 18:24:55

查看 Orchard.Comments 模块中的 CommentsService。 Orchard.Comments.Services.CommentsService。它非常接近您所需要的。由于服务返回查询,您可以添加一些额外的排序,如下所示......

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

类似的东西。

Check out the CommentsService in the Orchard.Comments module. Orchard.Comments.Services.CommentsService. It's really close to what you need. Since the service returns the query, you could just tack on some additional sorting like this...

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

Something like that.

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