[英]How to fetch data from a datareader when there's a class inside another one?
[英]How to fetch data from a class with two list inside?
我有一個里面有 2 個列表的類,不知道如何通過所有 2 個列表獲取所有數據,感謝您閱讀我的問題。
我的模型
namespace BaoCao.Models
{
public class ProductPage
{
public List<PRODUCT> listproduct { get; set; }
public List<TYPE_PRODUCTS> listtype_product { get; set; }
public static ProductPage getAll()
{
DB db = new DB();
ProductPage a = new ProductPage();
a.listproduct = db.PRODUCTS.ToList();
a.listtype_product = db.TYPE_PRODUCTS.ToList();
return a;
}
ProductPage()
{
}
}
}
我的觀點
namespace BaoCao.Controllers
{
public class ProductController : Controller
{
// GET: Product
public ActionResult Product()
{
var dssp = ProductPage.getAll();
return View(dssp);
}
}
}
產品.cshtml
@model BaoCao.Models.ProductPage
@foreach (var product in Model.listproduct) {
...
}
詳細信息在這里。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.