我有三个实体,如下所示。将LINQ转换为实体不包含到Lambda表达式中
Student { StudentID, Name, Age }
Parent { ParentID, Name, Age }
StudentParent { StudentParentID, StudentID, ParentID }
我需要得到一个IQueryable列表的学生是一定年龄,没有父母。我目前正在使用下面的代码工作。
IQueryable<Student> Student s = from s in db.Students
where s.Age == 18
where !(from sp in db.StudentParent where sp.StudentID == s.StudentID select sp.StudentID).Contains(s.StudentID)
select s;
我只想帮助将其转换为Lambda表达式。
有一个类似的问题,有人问了一下:http://stackoverflow.com/questions/3739246/linq-to-sql-not-contains-or-not-in。答案比迄今为止的答案更简洁一些。 – 2011-12-18 02:54:43