var s = myInventoryEntities.p_Forms().Select(i => new { i.Customer, i.Order_ID }).Distinct().ToList();
ViewBag.MyData = s;
return View();
这给了我使用一个IEnumerable <匿名类型>动态类型视图中
{ Customer = "Bob", Order_ID = 2644550 }
在我的剃刀代码
我遍历数据
@foreach (var x in @ViewBag.MyData){
x.Customer // Does not exist! :(
}
请帮帮忙!
“对象”不包含“客户”
你需要的'@'X之前?难道只是'x'? – 2012-08-09 18:12:39
@DavidHoerster:不需要,在这种情况下 – Shyju 2012-08-09 18:35:28