LINQ in Action roller

How to select rows whose ids are contained in a list/array

Hi, I'm trying to do the LINQ equivalent of the following SQL SELECT * from tbl where id IN (10, 20, 30) which would return all rows with id equal to 10, 20 or 30. I have an array/list in code containing the values e.g. 10, 20 & 30. I want to return all rows whose ids are in this array. I have tried var q = from x in tbl where arrayOfIds.Contains(x.id) but this hasn't worked. Any help greatly appreciated. Read More...
Published Monday, March 19, 2007 12:19 PM by MSDN Forums: LINQ Project General
Anonymous comments are disabled

Featured Item

This Blog

Sponsoring

Syndication