Если StudentId
в вашей таблице Marks
является внешним ключом (а если нет, то почему бы и нет?), Вы должны просто сделать:
var studentList = (from student in context.Student
select new
{
student.RollNo, // no need to explicitly name the properties if they're the same name as the property you're selecting
student.Name,
student.PhoneNo,
student.Marks // LINQ to SQL will do the join automagically
}).ToList();
Я также предполагаю, что вына самом деле хотите List<T>
- чтобы получить тот, что вам нужно позвонить .ToList()
.