【发布时间】:2020-11-22 21:02:38
【问题描述】:
我需要用 Linq 加入 4 个表。但它告诉我这个错误:
错误 1 无法将类型 'System.Collections.Generic.List' 隐式转换为 'System.Collections.Generic.List' E:\MyProject\GoKhoda\GoKhoda\Areas\Classes\StudentsFunc.cs 20 20 GoKhoda
这是我的代码:
public List<Tbl_Students> ShowAllStudents()
{
var qstudent = from s in _db.Tbl_Students
join pr in _db.Tbl_Pye_Reshte on s.StudentID equals pr.StudentID
join r in _db.Tbl_Reshte on pr.ReshteID equals r.ReshteID
join p in _db.Tbl_Paye on pr.PayeID equals p.PayeID
orderby p.PayeID descending
select new { StudentName = s.StudentName, StudentFamily = s.StudentFamily, StudentImage = s.StudentImage, StudentPayeName = p.PayeName, StudentReshtName = r.ReshteName };
return qstudent.ToList();
}
为什么显示错误?我该如何解决这个问题?
【问题讨论】:
-
例外情况并没有比我们能告诉你的少很多。