Reputation: 7788
I have a DataTable in C# which I am returning from SQL server. I am passing this datatable to couple separate functions.
Can I send some sort of query directly to the DataTable, instead of looping over all records?
for example
set|subset|value
1 |1 |40
1 |2 |30
1 |3 |35
2 |1 |10
2 |2 |15
2 |3 |20
how can I do something like SELECT DISTINCT SET FROM TABLE
and get values 1
and 2
Upvotes: 5
Views: 3876
Reputation: 6554
Just use LINQ, it's easier.
var result = yourTable.AsEnumerable().Select(f => f.Field<int>("Set")).Distinct();
Upvotes: 6