1

構文に問題があります。

public class Student
{
   int StudentId;
   string Name;
}

public class Course
{
   int CourseId;
   List<Student> Students;
}


int[] studentIds = { 5, 7, 12 };
List<Course> allCourses = myDataContext.Courses.ToList();

ラムダ式またはクエリ式を使用して、配列内の任意の学生を含むすべてのコースのフィルターされたリストを取得するにはどうすればよいstudentIdsですか?

4

1 に答える 1

5
var result = from course in allCourses
             where course.Students.Any(x => studentIds.Contains(x.StudentId))
             select course;
于 2012-01-12T22:09:29.843 に答える