Sitecore 8.0 意外的数据源输出

Sitecore 8.0 Unexpected Datasource Output

我正在尝试显示一个 table,其中包含存储桶中所有项目的列表。我创建了以下 ActionResult:

public ActionResult Outage()
{
    if (IsDataSourceItemNull) return null;

    IEnumerable<SimpleItem> items = DataSourceItems.Select(x => new SimpleItem(x)).Where(x => SiteConfiguration.DoesItemExistInCurrentLanguage(x.Item));
    SimpleItemList results = new SimpleItemList(DataSourceItem["Title"], items);
    return !items.IsNullOrEmpty() ? View(results) : ShowListIsEmptyPageEditorAlert();
}

控制器渲染的code-behind是这样的:

@model LaunchSitecore.Models.SimpleItemList

<div>
    <table class="table table-striped">
        <thead>
            <tr>
                <th>Title</th>
                <th>Date</th>
                <th>Description</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model.Items)
            {
                <tr>
                    <td>@Html.Sitecore().Field("Title")</td>
                    <td>@Html.Sitecore().Field("Date")</td>
                    <td>@Html.Sitecore().Field("Description")</td>
                </tr>
            }
        </tbody>
    </table>
</div>

模型如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Sitecore.Mvc;
using Sitecore.Mvc.Presentation;
using System.Xml.Serialization;
using Sitecore.Data.Items;
using Sitecore.Links;
using LaunchSitecore.Configuration;

namespace LaunchSitecore.Models
{
    public class SimpleItemList
    {
        public string Title { get; protected set; }
        public IEnumerable<SimpleItem> Items { get; protected set; }

        public SimpleItemList(string title, IEnumerable<SimpleItem> items)
        {
          Title = title;
          Items = items;
        }
    }
}

我在渲染中使用此查询作为数据源:

最后,这是我在我的页面上看到的:

我不确定为什么要返回我的查询标题...生成的次数与我拥有的 "outage" 项的数量有关,但这显然不是我想要的输出。我应该看到 table 中显示的实际 "outage" 内容项的数据。谁能诊断我的问题?

似乎如果您不提供项目 以及 字段名称,那么它将在 上下文项目,我猜这是你的查询。因此,您也可以尝试提供 item,如下所示:

@foreach (var item in Model.Items)
{
    <tr>
        <td>@Html.Sitecore().Field("Title", item)</td>
        <td>@Html.Sitecore().Field("Date", item)</td>
        <td>@Html.Sitecore().Field("Description", item)</td>
    </tr>
}

此处有更多信息:Rendering Content