求用Linq或EF实现这个SQL语句一样的效果
删除表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断,只留有rowid最小的记录
delete from people
where peopleId in (select peopleId from people group by peopleId having count(peopleId) > 1)
and rowid not in (select min(rowid) from people group by peopleId having count(peopleId )>1)
招募高手.
------解决方案--------------------var ToDelete = db.people.GroupBy(x => x.peopleId).SelectMany(x => x.OrderBy(y => y.rowid).Skip(1));
foreach (var item in ToDelete) db.DeleteObject(item);
db.SaveChanges();