I have a general result having different columns including id column. I also have a List which has a set of id‘s. I want to get result where List item(id) matches the Id column value.
I tried doing this in a loop:
foreach(int Uid in idList)
{
queryResults = queryResults.Where(security => security.id== Uid);
}
But this gives me single record in queryResults which is for the last Uid in List. What I want is, records for all Uid‘s in List should be there in queryResults.
You will need to match the id of every item to the ids stored in your
idList. This can be achieved by means of theWhere-extension used on yourqueryResultin combination with theContains-method used on theidList:This will check for every item of the
queryResultwhether itsSecuritiesIdis contained in the list containing the relevant ids.