I’m querying a datatable using linq, I then query the results to filter out what I want, the problem is that I need to query it for each value of an array these values are like this ,2, or ,22, or ,21, etc
so I usually do this
results = from a in results
where a.countryId.ToString().Contains(value)
select a;
what I would like to do is this
foreach(string str in arrayval)
{
results += from a in results
where a.countryId.ToString().Contains(str)
}
can anyone help or give me some clues
thanks
Looks like you want to select results based on comparison from the array values. Something like.
Select * from table where ID in (1,2,3). Instead of concatenating results you can try the following query.if your
arrayvalis an int type array then you may remove.ToString()at the end ofa.CountryID