MVC 4 how pass data correctly from controller to view

前端 未结 4 1330
长发绾君心
长发绾君心 2020-11-29 08:30

I currently have a controller with a LINQ statement that i am passing data from to my view. I am trying to find a more efficient and better coding method to do this. My hom

4条回答
  •  北荒
    北荒 (楼主)
    2020-11-29 09:16

    Use models instead

    var Melt
     Furnace1 =
           (from item in db.tbl_dppITHr
           where item.ProductionHour >= StartShift && item.ProductionHour <= EndDate
           select item).Sum(x => x.Furnace1Total),
    return View("SomeVIew",MeltFurnace1)
    

    In view@model "TypeOfMeltFurnace1"

    You can reference model in view by property Model

提交回复
热议问题