私はLinqと4つのテーブルを結合する必要があります。それは私にこのエラーが表示さ:暗黙のうちに 'System.Collections.Generic.List asp mvcに変換できません
エラー1は、暗黙的に 'System.Collections.Generic.List' Eに型 'System.Collections.Generic.Listを<>' に変換できません:\ MyProjectと\ GoKhoda \ 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(); }
なぜ私は、エラー表示:\クラス\ StudentsFunc.cs 20 20 GoKhoda
が、これは私のコードですか?どうすればこの問題を解決できますか?ただobject
以外何に変換することcan't whch匿名型を作成します
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 Tbl_Students { StudentName = s.StudentName, StudentFamily = s.StudentFamily, StudentImage = s.StudentImage, StudentPayeName = p.PayeName, StudentReshtName = r.ReshteName };
return qstudent.ToList();
Select new { ... }
:
例外は、私たちがあなたに伝えることができるほど少ないとは言いません。 –