Hi all,
currently i'm facing the problem with nested linq.
here is my tables and now i am developing MVC4 Razor web application.
student
student_id,studentname,description
book
book_id,student_id,bookname,checkitout
booker
bookerid,book_id,bookername,bookerdescription
i create the model for displaying
public class student_model{
public int student_id {get;set;}
public string studentname {get;set;}
public string bookname {get;set;}
}
i want to write nested LINQ for booker. so i use the following 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 {
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;
}
It is wrong nested LINQ. so how should i do it to make a filter bookers.book_id = bk.book_id ? and how should i return (List<student_model)?>
Thanks
frog