Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Every One

I am new to Linq, I want to implement "where in" of Sql using linq.

Requirements are as under

I have a list<int>, Now i want to query the table that provide me all the
rows where "id" is in the list.

img id is my list having int values.
The linq code is as under
C#
var db = new CarDataContext(); 
var deleteImages = from deletimg in db.tbl_Car_Images 
                   where imgId.Contains(delete.Car_Id)
                     select deletimg;


Thanks in Advance
Posted
Updated 16-Jan-12 19:36pm
v2

try something like this

C#
var q = from item in listItems where item.Contains("id") select item;


or a shorter version

C#
var q = itemsList.Where((item) => item.Contains("id"));


This assumes that id is a string value. To give a proper example you should state the class of item in the list as well as the property you wish to check.
 
Share this answer
 
Comments
TanzeelurRehman 17-Jan-12 1:18am    
Hope that it will work, but my situation is different, I have table not list, Where the id in the table must be present in the list item,
img id is my list having int values.
The linq code is as under
var db = new CarDataContext();
var deleteImages = from deletimg in db.tbl_Car_Images where imgId.Contains(delete.Car_Id) select deletimg;
Wayne Gaylard 17-Jan-12 1:22am    
You should update your question and put sample code to explain exactly what you are trying to do.
TanzeelurRehman 17-Jan-12 1:23am    
I have replied to you in the comment,Check plz
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900