lzth.net
当前位置:首页 >> 求助Linq问题,查处重复数据 >>

求助Linq问题,查处重复数据

text类型就别做DISTINCT了,效率会让你吐血。 实在想做的话,尝试newslist = newslist.OrderBy(x=>x.nID).ToList().Distinct(); 将数据加载入内存,用CLR来做DISTINCT

Distinct方法的第二重载可以 Enumerable.Distinct (IEnumerable, IEqualityComparer), 例如数据类为 class School { public int Id { get; set; } public string Name { get; set; } //是否重点学校 public bool IsKeySchool { get; set; } } ...

DataTable dataSource = new DataTable(); var result = (from d in dataSource.AsEnumerable() select d["id"]).Distinct(); DataTable newTable = new DataTable(); foreach (var item in result) { newTable.Rows.Add(item); }

public static void cs() { System.Data.DataTable dt = new System.Data.DataTable(); dt.Rows.Add(""); var quer = from tb in dt.AsEnumerable() group tb by tb.Field("xx") into x select new{ a=x.Key, b=x }; foreach(var c in quer) { i...

select A.name , MAX(B.tit ) AS titfrom A inner join B on A.id = B.Aidgroup by A.id

var value=(from v in db.tbl select v.name).Distinct().ToList();

var userlist=(from user in dc.Users where user.name.contains(key) select user).Distinct(); return userlist.ToList();

1 2 3 4 5 6 7 8 9 DataTable dataSource = new DataTable(); var result = (from d in dataSource.AsEnumerable() select d["id"]).Distinct(); DataTable newTable = new DataTable(); foreach (var item in result) { newTable.Rows.Add(item...

List list; list= (from p in list select p).Distinct().ToList();

网站首页 | 网站地图
All rights reserved Powered by www.lzth.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com