Use myDT.AsEnumerable.Where to pull only certain columns

@Yoichi you helped me build the below query. I did make some changes, including adding the r(“ON_PREVIOUS_TABS”) part. That’s a necessary filter but I don’t actually want the ON_PREVIOUS_TABS column in the data that’s returned. Is there a way in a query like this to specify the columns I want?

For example’s sake, let’s say I want the resulting data only to contain the columns Customer Number, Customer Name, and Loan Number.

myDT.AsEnumerable.Where(Function(r) r("CREATED_IN_NCINO").ToString.ToUpper <> "YES" And r("CREATED_IN_NCINO").ToString.ToUpper <> "NO" And r("ON_PREVIOUS_TABS").ToString <> "YES" AndAlso DateDiff(DateInterval.Day,Now,DateTime.ParseExact(Split(r("Maturity Date").ToString," ")(0),"M/d/yyyy",System.Globalization.CultureInfo.InvariantCulture)) = CInt(Config("Days Until Maturity").ToString)).ToList

Oh, also, I’m assigning that to loansList and then later…

loansList.Take(1).CopyToDataTable

So maybe I can keep only the desired columns somehow from that expression instead of the original myDT.AsEnumerable

Ok well I solved my own problem. This worked on the second expression:

loansList.Take(1).CopyToDataTable.DefaultView.ToTable(false,{“CREATED_IN_NCINO”,“AUTOMATION_NOTES”,“Customer Name”,“Customer Number”,“Loan Number”})

1 Like

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