Linq for selecting first 3 column values

Hello All,

I Have data table with n number of column, where the column name will vary often. My requirement is i need to get the first 3 column value as data table - Any suggestion pls

@Fresher
Linq as also other options can solve your sceanrio:

LINQ: - prepare an empty datatable with build datatable defining 3 columns
(From d In dtDataVar.AsEnumerable
let ra = d.ItemArray.Take(3).toArray
Select newDTVar.Rows.Add(ra)).CopyToDataTable

but also with the filter DataTable activity we can do it (even less work to do):
instead of column name we can use the column index
grafik

other options we can describe in case of both options from above will not work (but this would surprise us)

3 Likes