the_bachelor
asked on
Dataset Datable or Dataview Subset Exclude columns
I have a datatable initiaDT with columns A, B, C, ... H.
I want to have a subset of such datable subsetDt with columns B, D, G
Is there a way to do that w/o looping through every row of initiaDT ?
Same thing applies for a Dataset or Dataview.
I want to have a subset of such datable subsetDt with columns B, D, G
Is there a way to do that w/o looping through every row of initiaDT ?
Same thing applies for a Dataset or Dataview.
ASKER
I thought about doing something similar but that didnt seem "elegant" to me.
I was hoping that I'd be able so run some sort of adhoc select on the data (set, table, or view)
I was hoping that I'd be able so run some sort of adhoc select on the data (set, table, or view)
Are you talking about from the database side, or from in-memory DataTable/DataSet?
Bob
Bob
ASKER
in/memory Dataset/DataTable/Dataview side
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I havent found anything helpful. I guess I'm gunna have to agree with you there LeanedOne.
Maybe I should write my own.
Maybe I should write my own.
With the advent of LINQ you can write an expression which would limit down the returned columns within a project much like a SQL select command. When running a LINQ expression on a DataTable one of the options for getting at the results is to use the ToDataTable method which should return a DataTable with the projected columns from your expression. This methodology allows many of hte SQL like SET based commands to be done within C# in a way that is concise and probably more efficient than copying a DataTable and then removing columns.
Bob