我在数据库中有一对多的关系(我使用实体接口来生成2个对象之间的关联)
我收到错误:
绑定列需要字段或属性访问表达式
My code:
in view:
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();
在实体模型中:
public ObjectSet<Deliveries> Deliveries
{
get
{
if ((_ Deliveries
== null))
{
_Deliveries = base.CreateObjectSet<Deliveries>("Deliveries");
}
return _Deliveries;
}
}
private ObjectSet<Deliveries> _Deliveries;
在交付中我没有任何空值。
问题出在哪里?
columns.Bound 仅接受 int 或 string 等原语。
您不能聚合或转换对象作为示例:
o.Deliveries.Sum(m=>m.deliveryTime)
你确实创建于Deliveries
对象参数如下:
public int SumDeliveries
{
get { return this.Sum(m=>m.deliveryTime); }
}
所以你可以将其绑定到网格上。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)