Linq Query question regarding DT

I have a raw data excel, i want a datacolumn from that which should have uniquevalue. i can do it using for each row and adding in seprate column but i want to do it with the liq query, can someone help.

Hii @Shubham_Kinge ,
what i understood from your requirement is you want a particular column in your excel from which you should get only the unique value. If this is right then you can use below expression.

YourInputDT.DefaultView.ToTable(true,“YourColumnName”)

This will return the single column with the unique values.

Thanks,

1 Like

Try this one may be this will help you

dtYourDatatable.DefaultView.ToTable(True,“ColumnName”)

1 Like

Hi @Shubham_Kinge ,

Check this below query to get unique rows based on a column,

dt_Grouped = (From d In dt_Input
Group d By k=d("Your Column Name").toString.Trim Into grp=Group
Select grp.First).CopyToDataTable()

Hope this may help you :slight_smile:

5 Likes

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