LINQ-to-SQL: Searching against a CSV
- by Peter Bridger
I'm using LINQtoSQL and I want to return a list of matching records for a CSV contains a list of IDs to match. The following code is my starting point, having turned a CSV string in a string array, then into a generic list (which I thought LINQ would like) - but it doesn't:
Error
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:\...\
Code
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 };
Where do I go from here?