无法将类型 System.Collections.Generic.List<>' 隐式转换为 'System.Collections.Generic.List<>
Cannot implicitly convert type System.Collections.Generic.List<>' to 'System.Collections.Generic.List<>
我是 MVC4 的新手,我想实现 WebGrid,在检索 model.activity 的数据时工作正常。为了澄清起见,我将两个表结合起来获取数据。
这里显示的错误是这样的
无法将类型 'System.Collections.Generic.List' 隐式转换为 'System.Collections.Generic.List
请帮我解决这个问题。提前致谢
public class MyViewModel
{
public List<Tbl_Activity> activity;
public List<Tbl_Clarification> clarification;
}
public class ClarificationEntities
{
public int ClrNo { get; set; }
public Nullable<int> DailyReportID { get; set; }
public string ReportingMgrComment { get; set; }
public Nullable<System.DateTime> CreatedOn { get; set; }
public string StaffComment { get; set; }
public Nullable<int> CreatedBy { get; set; }
public string Name { get; set; }
}
我正在向模型添加数据以在 WebGrid 中显示
MyViewModel model = new MyViewModel();
model.activity = db.Tbl_Activity.Where(x => x.DailyReportID == driD).ToList();
model.clarification = (from c in db.Tbl_Clarification
join u in db.Tbl_Users on c.CreatedBy equals u.CreatedBy
where c.DailyReportID == did
select new ClarificationEntities
{
ClrNo = c.ClrNo,
ReportingMgrComment = c.ReportingMgrComment,
StaffComment = c.StaffComment,
DailyReportID=c.DailyReportID,
Name=u.Name
}).ToList();
return View(model);
MyViewModel
clarification
字段的类型错误...
试试下面的方法
public class MyViewModel
{
public List<Tbl_Activity> activity;
public List<ClarificationEntities> clarification;
}
我是 MVC4 的新手,我想实现 WebGrid,在检索 model.activity 的数据时工作正常。为了澄清起见,我将两个表结合起来获取数据。
这里显示的错误是这样的 无法将类型 'System.Collections.Generic.List' 隐式转换为 'System.Collections.Generic.List
请帮我解决这个问题。提前致谢
public class MyViewModel
{
public List<Tbl_Activity> activity;
public List<Tbl_Clarification> clarification;
}
public class ClarificationEntities
{
public int ClrNo { get; set; }
public Nullable<int> DailyReportID { get; set; }
public string ReportingMgrComment { get; set; }
public Nullable<System.DateTime> CreatedOn { get; set; }
public string StaffComment { get; set; }
public Nullable<int> CreatedBy { get; set; }
public string Name { get; set; }
}
我正在向模型添加数据以在 WebGrid 中显示
MyViewModel model = new MyViewModel();
model.activity = db.Tbl_Activity.Where(x => x.DailyReportID == driD).ToList();
model.clarification = (from c in db.Tbl_Clarification
join u in db.Tbl_Users on c.CreatedBy equals u.CreatedBy
where c.DailyReportID == did
select new ClarificationEntities
{
ClrNo = c.ClrNo,
ReportingMgrComment = c.ReportingMgrComment,
StaffComment = c.StaffComment,
DailyReportID=c.DailyReportID,
Name=u.Name
}).ToList();
return View(model);
MyViewModel
clarification
字段的类型错误...
试试下面的方法
public class MyViewModel
{
public List<Tbl_Activity> activity;
public List<ClarificationEntities> clarification;
}