目前我正面临嵌套LINQ的问题。MVC4中的嵌套Linq剃须刀
这里是我的表,现在我正在开发MVC4 Razor Web应用程序。
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;}
}
大家好,这里是我的表,现在我正在开发MVC4剃刀Web应用程序。 我想为booker编写嵌套的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
)?
感谢 青蛙