Linq For Selecting Cities

I know how to write for one value.
(
From row In ExtractDataTable
Where CStr(row(“Name”)) =“New Delhi”
Select row
).CopyToDataTable

How to select multi cities?

HI @Manju_Reddy_Kanughula

Try this

(
From row In ExtractDataTable
Where CStr(row(“Name”)) =“New Delhi” andalso CStr(row(“Name”)) =“TN” 
Select row
).CopyToDataTable

or

(
From row In ExtractDataTable
Where CStr(row(“Name”)) =“New Delhi” and CStr(row(“Name”)) =“TN” 
Select row
).CopyToDataTable

you need to add and or andalso give your next condition and so on

Hope this Helps!

Regards
Sudharsan

1 Like

Hi @Manju_Reddy_Kanughula ,

Maybe the below Expression is what you require :

(
From row In ExtractDataTable
Where listOfCities.Contains(CStr(row("Name")))
Select row
).CopyToDataTable

Here, listOfCities is an Array/List of String type variable, which contains different city names like below :

listOfCities = {"New Delhi","Punjab","Mumbai"}

Let us know if you requirement is different.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.