我对数据进行了分组,我想将这些数据与模型一起发送到视图。如何将属性写入视图模型
工作计划类
public class WorkPlan:IEntity
{
public int WorkPlanId { get; set; }
public int PlanNumber { get; set; }
public string Day { get; set; }
public string Lesson { get; set; }
public string Description { get; set; }
public bool IsActive { get; set; }
}
工作计划视图模型
public class WorkPlanViewModel:BaseViewModel
{
public List<WorkPlan> WorkPlans { get; set; }
public WorkPlan WorkPlan { get; set; }
}
行动
public IActionResult Index()
{
WorkPlanViewModel model=new WorkPlanViewModel();
model.Message=new Message();
var allWorkPlan = workPlanService.GetAll();
var groupPlan = allWorkPlan.GroupBy(p => p.PlanNumber)
.Select(p => new {PlanNumber=p.Key, Day= p.GroupBy(b => b.Day).ToList() } ).ToList();
return View(model);
}
groupPlan 是我的分组数据
慕容708150
相关分类