如何将这个sql转换为linq
sql语句
select * from Viewstscore where stu_id in (select stu_id from Viewstscore group by stu_id having count(*)>1)
目的
视图Viewstscore中 字段的值可能有重复,我要查找Viewstscore 中stu_id有 重复的数据,用linq不知如何写
[解决办法]
- C# code
var query = Viewstscore.Where(y => (from x in Viewstscore group x by x.stu_id into g select g.Key).Contains(y)).Select(x => x);
[解决办法]
- C# code
var query = Viewstscore.Where(y => (from x in Viewstscore group x by x.stu_id into g select g.Key).Where(z => z.Count() > 1).Contains(y)).Select(x => x);