Posts Tagged ‘linq’

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