asp.net mvc 3 - How can I change this block of code to return only records associated with a specific ID.? -
i’m trying create query returns records associated 1 person’s id.
i’ve tried this:
viewmodel.students = db.students.where(sd => sd.studentid==9); but don’t know how cast instructorindexdata() or whether should way. how can change block of code return student id==9?
var viewmodel2 = new instructorindexdata(); viewmodel.courses = viewmodel.instructors.where( => i.instructorid == 2).single().courses viewmodel.enrollments = viewmodel.courses.where( x => x.courseid == 600).single().enrollments; viewmodel2.students = db.students.where(sd => sd.studentid==9); return view(viewmodel); instructor index data:
public class instructorindexdata { public ienumerable<instructor> instructors { get; set; } public ienumerable<course> courses { get; set; } public ienumerable<enrollment> enrollments { get; set; } public ienumerable<student> students { get; set; } public ienumerable<assignment> assignments { get; set; } }
Comments
Post a Comment