Filter column A and check if column B starts with "ABC"

Hi friends, is there a fast way of doing this using LINQ or select?

E.g.
Column A | Column B
Solid | Hello
Solid | World
Liquid | It’s
Liquid | Been
Gas | A
Gas | While

Filter Column A to Solid and check if Column B contains value that starts with “Wo”.

I need to filter Column A with Solid.

@iamthejuan
give a try on following:

(From d In yourDtVar.AsEnumerable
Where d(0).toString.Trim.Equals(“Solid”) And d(1).toString.Trim.StartsWith(“Wo”)
Select d).toList

returning a list of datarows (e.g. assignment to variable: drResult)

with drResult.Count > 0 you can check if there was a result returned back or not and get a datatable
true: drResult.CopyToDataTable
false: yourDtVar.Clone

4 Likes

Thank you Peter @ppr!

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