首页 > 解决方案 > linq 查询从组中获取第一条记录

问题描述

我有一个联系人实体表的记录列表,其中每个联系人都有一个 accountID。我需要为每个 gpa 较少的帐户(在帐户列表中)获取联系人记录。

这是我的尝试:

var stud = (from s in crm.contact
            where s.accountID != null && accountList.Contains(s.accountID.Id)
            orderby s.gpa
            group s by s.accountID.Id into stugrp
            select new contactTest
            {
                account= stugrp.First().account.Id,
                gpa= stugrp.First().gpa.Value
            }).Distinct().ToList();

accountList = accountid 的列表。

在这里,我在 where 条件错误中变得无效。有什么帮助吗?

标签: sqllinqcrm

解决方案


推荐阅读