C# LINQ到SQL:根据CSV进行搜索

C# LINQ到SQL:根据CSV进行搜索,c#,sql,linq,linq-to-sql,generics,C#,Sql,Linq,Linq To Sql,Generics,我正在使用LINQtoSQL,我想返回一个CSV的匹配记录列表,该CSV包含一个要匹配的ID列表。以下代码是我的出发点,将字符串数组中的CSV字符串转换为通用列表(我认为LINQ会喜欢),但它没有: 错误 Error 22 Operator '==' cannot be applied to operands of type 'int' and 'System.Collections.Generic.List<int>' C:\Documents and Settings\....\

我正在使用LINQtoSQL,我想返回一个CSV的匹配记录列表,该CSV包含一个要匹配的ID列表。以下代码是我的出发点,将字符串数组中的CSV字符串转换为通用列表(我认为LINQ会喜欢),但它没有:

错误

Error 22 Operator '==' cannot be applied to operands of type 'int' and 'System.Collections.Generic.List<int>' C:\Documents and Settings\....\Search.cs 41 42 C:\...\
Error 22运算符“==”不能应用于“int”和“System.Collections.Generic.List”类型的操作数C:\Documents and Settings\..\Search.cs 41 42 C:\\
代码

    DataContext db = new DataContext();

    List<int> geographyList = new List<int>( Convert.ToInt32(geography.Split(',')) );

        var geographyMatches = from cg in db.ContactGeographies
                               where cg.GeographyId == geographyList
                               select new { cg.ContactId };
DataContext db=newdatacontext();
List geographyList=新列表(Convert.ToInt32(geography.Split(','));
var geographyMatches=来自数据库中的cg
其中cg.GeographyId==geographyList
选择新建{cg.ContactId};

从这里我该怎么办?

就像错误所说的那样,在
中,cg.GeographyId==geographyList
您试图将
int
列表进行比较。他们是完全不同的类型。我想您应该执行
geographyList.Contains(cg.GeographyId)
或其他类似的操作。

这就可以了-这种语法对我来说似乎很奇怪,但我看到了LINQ奇怪的SQL眼睛,它让我看不到这些类型的方法
var geographyMatches = from cg in db.ContactGeographies
                               where geographyList.Contains(cg.GeographyId)
                               select new { cg.ContactId };