【发布时间】:2011-01-30 21:18:27
【问题描述】:
基本上,我要做的是获取对象列表并根据多个条件对其进行过滤,其中一个条件是密钥不存在于另一个列表中。这是一个例子:
我的两个类是这样的:
public class Test
{
public string name;
public string instructor_name;
public string course;
}
public class Appointment
{
public string site;
public DateTime forWhen;
public string testName;
}
我想通过查看课程并确保 List
SELECT new Group<Test>(c.Key, c)
FROM tests in testList
WHERE tests.Course != "Science"
AND tests.name NOT IN (SELECT testName FROM appotList)
但是,我不知道如何在 LINQ 中执行此操作。有什么想法吗?
【问题讨论】:
-
你可能想看看 SQL 的第一行...它不是 SQL :)
-
我意识到这一点,但我并不想在 SQL 中做到这一点。如果我在 SQL 中这样做,那只是我会使用的格式。我这样写是为了让人们更好地了解我在 LINQ 中试图做什么。