Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

extract data from a dataset

I have a dataset that gets populated from a stored proc in sql server. I have a column that has lets say has a set of values. I do not know what those values are. All I know is that they of the type "string". I want to extract all the distinct values from that column.

like image 531
zack Avatar asked Aug 25 '26 10:08

zack


1 Answers

You can use a DataView and set its RowFilter to the desired condition:

var view = new DataView(dataset.Tables["Table"]);
view.RowFilter = "Column = 42";

UPDATE: based on your updated question, you can use LINQ:

var table = dataset.Tables["Table"].AsEnumerable();
var distinctValuesForColumn = 
  table.Select(row => (string)row["Column"]).Distinct();
like image 134
Jordão Avatar answered Aug 27 '26 23:08

Jordão



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!