Sunday, March 28, 2010

Using LINQ to query dataset for Distinct

I just wanted to query (quickly) a dataset to get a distinct pair of values.
Heres a quick way of doing it

var distinctValues = (from row in dataSet.Tables[0].AsEnumerable()
select new
SomeColumn1 = row["SomeColumn1"],
SomeColumn2 = row["SomeColumn2"]

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.