Linq query to filter using between operator in Datatable

There will be several columns and please find below column DIv to filter in between values of 02
Input

Div Name
01 Ram 1
Ram 1
Ram 1
01 Ram 1
02 Ram 2
Ram 2
Ram 2
02 Ram 2

Output

Div Name
02 Ram 2
Ram 2
Ram 2
02 Ram 2

@Aravinthan ,

This query will filter the data if it is equal to 02, you need to use this in a Assign Activity with a datatable variable. Before that check the count of the below query is more than 1.

yourDataTable.AsEnumerable().Where(Function(x) Convert.ToInt32( x.Field(Of Object)("Div"))=2).CopyToDataTable()

Bro need all rows in between values of 02 only two rows selected. kindly help

give a try on:


grafik

(From x In  {"02"}
Let dl = dtData.AsEnumerable.toList
Let fi = dl.FindIndex(Function (d) d(0).toString.Equals(x))
Let li = dl.FindLastIndex(Function (d) d(0).toString.Equals(x))
From r In dtData.AsEnumerable.Skip(fi).Take(li-fi + 1)
Select r).toList

then branch: drResult.CopyToDataTable

2 Likes

works superb Great Thanks :star_struck:

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