LINQ-Get Only Columns without where

Hi

I have 4 columns say column1, column2, column3, column4. what is the linq query to get only col1 and col3. No where condition clause

Regards
Karthik

this should solve your problem

otherwise you can use

datatable.AsEnumerable.Select(function (x) {x(0), x(2)}).ToList

can send query syantax than method syantax

(from row in inputDT select {row(0), row(2)}).ToList

if I want it as a data table

(from row in inputDT select outputDT.Rows.Add({row(0), row(2)})).Copytodatatable

Hi @KarthikBallary
another way of acheveing this is by using below assign activity

suppose u had stored ur excel in dt1

then use below assign activity

dt2 = dt1.DefaultView.ToTable(False,{“col1”,“col3”})

then dt2 will only contains col1 and col3

Regards,
Nived N
Happy Automation

2 Likes

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