MVC working with id's

本文关键字:id working with MVC | 更新日期: 2023-09-27 18:11:53

我有这个显示作业订单的动作

public ActionResult jobOrderList(int id)
{
     var SelectedTruck = db.trucks.FirstOrDefault(s => s.id == id);
     List<JobOrderDetails> joList = db.joborders.Select(s => new JobOrderDetails()
     {
         id = s.id,
         DateStarted = s.date_started,
         Description = s.description,
         DateFinished = s.date_finished,
         SpareParts = s.spare_parts,
         kilometer_run = s.run,
         Quantity = s.quantity,
         truck_no = s.truck_no,
         worked_performed = s.worked_performed
     }).ToList();
     return View(joList);
}

如何显示所选卡车变量的作业订单列表。

MVC working with id's

我相信这就是你要问的。

     var SelectedTruck = db.trucks.FirstOrDefault(s => s.id == id);
List<JobOrderDetails> joList = db.joborders.Where(jo => jo.truck_no == SelectedTruck.truck_no).Select(s => new JobOrderDetails()
                 {
                     id = s.id,
                     DateStarted = s.date_started,
                     Description = s.description,
                     DateFinished = s.date_finished,
                     SpareParts = s.spare_parts,
                     kilometer_run = s.run,
                     Quantity = s.quantity,
                     truck_no = s.truck_no,
                     worked_performed = s.worked_performed
                 }).ToList();