绑定列需要ASP.NET MVC中的字段或属性访问表达式

bla*_*234 2 c# asp.net-mvc telerik

我在DB中有一对多关系(我使用实体接口生成2 obj之间的关联)我得到错误:绑定列需要字段或属性访问表达式

我的代码:

在视图中:

  Html.Telerik()
        .Grid<Y.Orders.Models.Orders>("orders")

        .Name("Orders")
        .DataKeys(dataKeys => dataKeys.Add(o => o.Id))
        //.Pageable(paging => paging.PageSize(20).Style(GridPagerStyles.PageSizeDropDown | GridPagerStyles.NextPreviousAndNumeric))
        .Columns(columns =>
        {
            columns.Command(commands =>
            {
                commands.Custom("comments").ButtonType(GridButtonType.Text).Text("Szczegó?y").Action("Index", "Komentarze");
            });
            columns.Bound(o => o.Tytul).Title("Title");
            columns.Bound(o => o.Deliveries.Sum(m=>m.deliveryTime)).Title("Time of order");
        })
        .Filterable()
        .Sortable(sort =>
        {
            sort.SortMode(GridSortMode.MultipleColumn); sort.OrderBy(ord =>
            {
                ord.Add(o => o.Time).Descending();

            });
        })
        .Groupable(grouping => grouping.Groups(groups =>
        {
            groups.Add(c => c.Users.Firms.Name);
        }))
        .Render();
Run Code Online (Sandbox Code Playgroud)

在实体模型中:

    public ObjectSet<Deliveries>  Deliveries
    {
        get
        {
            if ((_ Deliveries
 == null))
                {
                    _Deliveries = base.CreateObjectSet<Deliveries>("Deliveries");
                }
                return _Deliveries;
            }
        }
        private ObjectSet<Deliveries> _Deliveries;
Run Code Online (Sandbox Code Playgroud)

在交付中,我有任何空虚.

哪里有问题?

Use*_*ous 8

columns.Bound只接受原语为int或string.您不能聚合或转换对象作为示例:

o.Deliveries.Sum(m=>m.deliveryTime)
Run Code Online (Sandbox Code Playgroud)

您可以在Deliveries对象中创建一个参数,如下所示:

public int SumDeliveries 
{
  get { return this.Sum(m=>m.deliveryTime); }
}
Run Code Online (Sandbox Code Playgroud)

所以你可以在网格上绑定它.