I need to query a datatable with unknown columns to return a subset of columns.
Obviously this is easy with a dataview, but how about LINQ?
I will be passing a datatable and column names as parameters to the method which should do the query.
I have NO LINQ experience and what I’ve seen thus far on SO makes it seem that the only dyynamic part of LINQ would be the WHERE filter, and NOT which columns get selected.
Am I wrong?
If so could you provide me with a sample?
Here is a quick sample of how you could select any two columns using Linq to DataSet:
If you need to select a random number of columns, then this would get a little trickier, but hopefully this will get you headed in the right direction.