h1

Select distinct rows from Datatable using Linq

July 30, 2010

var distinctRows = (from DataRow dRow in dTable.Rows select new {col1=dRow[“dataColumn1”],col2=dRow[“dataColumn2”]}).Distinct();

foreach (var row in distinctRows)
{
var value1=row.col1.ToString();
var value2=row.col2.ToString();
}

don’t forget to add System.Linq Class

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: