I have two model in the controller ^^ may I know how to use it in the view?
public class SearchVM
{
public IEnumerable<StaffInfo> StaffInfo { get; set; }
public IEnumerable<TRecord> TRecord { get; set; }
}
public ActionResult Search(int? id)
{
var model = new SearchVM
{
TRecord = (from t in db.TRecordDBSet.Include("StaffInfo")
where t.StaffId == id
orderby t.StaffId, t.Tid
select t),
StaffInfo = (from t in db.StaffInfoDBSet
where t.StaffId == id
select t)
.ToList()
};
return View(model);
}
when I use it in the view mode the error occurs
view
@model IEnumerable<TrainingHourSystem.Models.TRecord>
the error msg :"傳入此字典的模型項目為型別 'THSystem.Controllers.TRecordsController+SearchVM',但是此字典需要型別 'System.Collections.Generic.IEnumerable`1[THSystem.Models.TRecord]' 的模型項目。