여기 내 모델입니다. 여기에 그 코드는 다음과 같습니다표시 목록
@using MyModel.MyTools.Orders.SumOrder
@model SumOrder
@{
ViewBag.Title = "View Invoice";
}
<h2>View Invoice</h2>
<table>
@foreach(var prod in Model.OCI)
{
<tr>
<td>
@prod.ClientLocation
</td>
</tr>
foreach (var orderItem in prod.Details)
{
<tr>
<td>
@orderItem.Product
</td>
<td>
@orderItem.ItemQuantity
</td>
</tr>
}
}
</table>
도시의 이름이지만, 다음 행에 나는이 얻을 제대로 표는 첫 번째 행 :
System.Collections.Generic.List 1[System.String] System.Collections.Generic.List
을 1 [System.Int32]
내가 읽을 수있는 형식으로 반환 된 목록을 가져올 수없는 이유와이 문제를 해결하는 방법을 누군가에게 설명 할 수 있습니까? 문자열 목록이 문자열로 동일하지 않기 때문에
// group the cartItems according to location
List<ViewInvoice> ordersGrouped = cartItems.GroupBy(c => new
{c.ClientLocation})
.OrderBy(c => c.Key.ClientLocation).Select(s =>
new ViewInvoice()
{
ClientLocation = s.Key.ClientLocation,
Details = new List<ViewInvoice.DetailsGroup>()
{
new ViewInvoice.DetailsGroup()
{
Product = s.Select(p => p.Product).ToList(),
ItemQuantity = s.Select(p => p.ItemQuantity).ToList(),
DeliveryDate = s.Select(p => p.DeliveryDate).ToList(),
OrderDate = s.Select(p => p.OrderDate).ToList(),
OrderNumber = s.Select(p => p.OrderNumber).ToList(),
PackageType = s.Select(p => p.PackageType).ToList(),
Price = s.Select(p => p.Price).ToList(),
ProductSize = s.Select(p => p.ProductSize).ToList()
}
}
}).ToList();
질문이 명확하지 않습니다. 컨트롤러를 보여줄 수 있습니까? Model.OCI가 ViewInvoice의 목록이라는 점을 감안할 때 정상적으로 작동합니다. 전체 오류를 알려주십시오. – Ammar