筛选不重复的sourceColumn数据,单Column
举例: DataTable billListDT =TblDistinct(dt, "OnlineRecordTicketNo");
public static DataTable TblDistinct(DataTable sourceTable, string sourceColumn)
{
try
{
var result = sourceTable.Clone();
var ht = new Hashtable();
foreach (var dr in sourceTable.Rows.Cast<DataRow>().Where(dr => !ht.ContainsKey(dr[sourceColumn])))
{
ht.Add(dr[sourceColumn], null);
var newRow = result.NewRow();
newRow.ItemArray = dr.ItemArray;
result.Rows.Add(newRow);
}
return result;
}
catch (Exception)
{
return null;