8,497
社区成员
发帖
与我相关
我的任务
分享
public static IEnumerable<TSource> DistinctBy<TSource, TKey>(
this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
{
HashSet<TKey> seenKeys = new HashSet<TKey>();
foreach (TSource element in source)
{
if (seenKeys.Add(keySelector(element))) { yield return element; }
}
}
ar d1 = (from p in tr.考试记录表
from pp in tr.考题分类表
where p.考题分类 == pp.id
where p.考试分数<100
where p.用户id == Common.Get_UserID
orderby p.id descending
select new { pp.考题分类名称, p.考试分数, p.id,p.答题个数,p.考题分类 }).DistinctBy(p=>
new { p.考题分类,p. 答题个数});