未過濾前:
過濾後(僅會過濾掉完全一樣的資料)
DataTable dt = this.JsonToDataTable("[{\"Code\":\"SortId\",\"Name\":\"SortId\"},{\"Code\":\"SortCode\",\"Name\":\"编号\"},
{\"Code\":\"SolutionName\",\"Name\":\"名称\"},{\"Code\":\"SortId\",\"Name\":\"SortId\"},{\"Code\":\"SortId\",\"Name\":\"SortId\"},
{\"Code\":\"SortId001\",\"Name\":\"SortId\"}]");
DataTable dtSort = dt.Clone();
var query = from t in dt.AsEnumerable()
group t by new { t1 = t.Field<string>("Code"),t2 = t.Field<string>("Name") } into m
select new
{
code = m.Key.t1,
name=m.Key.t2,
rowcount = m.Count()
};
if (query.ToList().Count > 0)
{
query.ToList().ForEach(q =>
{
DataRow dr = dtSort.NewRow();
dr["Code"] = q.code;
dr["Name"] = q.name;
dtSort.Rows.Add(dr);
});
}