1
所以這是我的控制器:如何在實體框架中迭代聯接查詢?
public ActionResult Index()
{
DBContext_Model db = new DBContext_Model();
var srmas = (
from SRMAs in db.SRMAs
join SRMAStatus in db.SRMAStatus on SRMAs.Id equals SRMAStatus.Id
join PurchaseOrders in db.PurchaseOrders on SRMAs.PONumber equals PurchaseOrders.PONumber
join Suppliers in db.Suppliers on PurchaseOrders.SupplierID equals Suppliers.SupplierID
select new {SRMAs.Id,SRMAs.PONumber,SRMAs.CreatedOn,Suppliers.SupplierName,SRMAStatus.StatusName,PurchaseOrders.PODate,PurchaseOrders.suppliersOrderNumber}
).ToList();
ViewBag.SRMAs = srmas;
return View();
}
現在我需要遍歷結果。我應該使用什麼類型來投射我的循環變量來獲取慾望領域?