所以我编写了一个简单的模块,并通过AdminMenu显示特定ContentItem的列表。除了寻呼机之外,一切正常。寻呼机显示所有 ContentItems的计数,而不是已过滤的列表。我确信这很简单,我很想念,但我无法理解它。
这是我的控制器代码:
public ActionResult List(ListContentsViewModel model, PagerParameters pagerParameters) {
var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
var query = _contentManager.Query<EventPart>(VersionOptions.Latest);
switch (model.Options.OrderBy) {
case ContentsOrder.Modified:
query.OrderByDescending<CommonPartRecord>(cr => cr.ModifiedUtc);
break;
case ContentsOrder.Published:
query.OrderByDescending<CommonPartRecord>(cr => cr.PublishedUtc);
break;
case ContentsOrder.Created:
query.OrderByDescending<CommonPartRecord>(cr => cr.CreatedUtc);
break;
}
var pagerShape = Shape.Pager(pager).TotalItemCount(query.Count());
var pageOfContentItems = query.Slice(pager.GetStartIndex(), pager.PageSize).ToList();
var list = Shape.List();
list.AddRange(pageOfContentItems.Select(ci => _contentManager.BuildDisplay(ci, "SummaryAdmin")));
dynamic viewModel = Shape.ViewModel()
.ContentItems(list)
.Pager(pagerShape)
.Options(model.Options);
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View((object)viewModel);
}
我做错了什么?
谢谢!
答案 0 :(得分:0)
好的,为了记录;当我评论说我认为这与.Query<EventPart>
有关时,我是对的。我不确定它背后的逻辑,但查询需要是:
var query = _contentManager.Query<EventPart, EventPartRecord>(VersionOptions.Latest);
...引用 PartRecord 。
如果有人能对其背后的逻辑提出意见,那么我(以及其他人阅读本文)可以更好地理解,那将是非常棒的!