How to get using linq only specific values from datatable

Hello!

I have this datatable.
How can i use linq/lambda expression to get the values from DRAW_Cnt column, only for abc and save them in a list.
For exmaple for abc i have List = {“0”,“1”}

Hi @Andrei_Croitoru ,
Use below query
dt.select("Code= 'abc'").CopyToDataTable()
OR
(From p in dt.Select() where p("Code").Equals("abc") select p).ToArray.CopyToDataTable()

Regards,
Arivu

Give a try in

vals =

(From d in yourDatatableVar.asenumerable
Where d(yourcolnameorindex).tostring.trim.toupper.equals(“ABC”)
Select v=d(yourcolnameorindex).tostring.trim).distinct().tolist

This is not my question

Hi @Andrei_Croitoru,

DataTableGroupByToList.xaml (7.0 KB)

listVariable = (from x in dtInput.AsEnumerable.Where(function(x) x(“Code”).ToString.Trim.Equals(“abc”))Select Convert.ToString(x(“DRAW_Cnt”))).ToList

Thanks!

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