現在、ネストされたlinqの問題に直面しています。
これが私のテーブルで、現在MVC4RazorWebアプリケーションを開発しています。
student
student_id,studentname,description
book
book_id,student_id,bookname,checkitout
booker
bookerid,book_id,bookername,bookerdescription
表示用のモデルを作成します
public class student_model{
public int student_id {get;set;}
public string studentname {get;set;}
public string bookname {get;set;}
}
こんにちはすべてここに私のテーブルがあり、今私はMVC4RazorWebアプリケーションを開発しています。ブッカー用にネストされたLINQを記述したい。したがって、次のLINQを使用します。
public List<student_model> finder (int stuid){
var stubk = (from stu in contx.students
join bk in contx.books on stu.student_id equals bk.student_id
where stu.student_id == stuid
select new {
//here is wrong
student = from bker in contx.bookers
where bker.book_id=bk.book_id
select new student_model{
student_id = stu.student_id,
studentname = stu.studentname,
bookname = bk.bookname
}
}).ToList();
var next = stubk.Select(md=>md.student)
return (List<student_model>) next;
}
ネストされたLINQが間違っています。では、フィルターを作成するにはどうすればよいbookers.book_id = bk.book_id
ですか?そして、どのように返す必要がありますか(List<student_model
)?
ありがとうカエル