去重取最新数据
2019-10-08 本文已影响0人
飞天猪Pony
Lambda:
var uLogQuery = db.cus_UserCRMLog.GroupBy(s => new { s.CRMUserID }).Select(g => g.OrderByDescending(p=>p.ID).FirstOrDefault()).toList();
SQL:
select * from table where id in (select max(id) from table group by [去除重复的字段名列表,....])