Replacement for select query

DT.Select(" Convert(["+str_CurrentVC+"],‘System.String’)= ‘"+ str_CurrentSCValue+"’")
Can anyone suggest the linq query instead of this select query

Hi @Amrutha.mg

Try this

DT.AsEnumerable.Where(Function (x) x(str_CurrentVC).ToString.Equals(str_CurrentSCValue)).CopyToDataTable

Query version

(From r in DT
Where r(str_CurrentVC).ToString.Equals(str_CurrentSCValue)
Select r).CopyToDataTable

thank you

i’m Getting error for empty case

@Amrutha.mg what is to be done with the empty values according to the SOP?

If the empty values are to be discarded then filter out the values first and then use the query.

instead of CopyToDataTable use ToArray

Can you share the sample data and the required output?

Thank you so much it is working with Toarray

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