LINQ-to-SQL: Searching against a CSV

Posted by Peter Bridger on Stack Overflow See other posts from Stack Overflow or by Peter Bridger
Published on 2010-03-09T11:03:12Z Indexed on 2010/03/09 11:06 UTC
Read the original article Hit count: 223

Filed under:
|
|
|
|

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?

© Stack Overflow or respective owner

Related posts about LINQ

Related posts about linq-to-sql