sql - 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 条件错误中变得无效。有什么帮助吗?
解决方案
推荐阅读
- ruby-on-rails - Rails RoutingError 来自约束失败(IP 将文件列入白名单)
- php - WordPress 自定义帖子类型:如何在标签档案中显示 (tag.php)
- revit-api - 如何在 Revit API 中找到 Ramp 着陆空间和中间着陆?
- php - 为什么 Eloquent 文档中的 hasManyThrough 不起作用?
- javascript - 如何从 jsp/servlet 中表格数据单元格内的文本框中获取值?
- scala - 使用 Scala 将数据框的结果作为另一个数据框的变量
- powershell - 在批处理文件中以另一个 Windows 用户身份运行单个命令
- javascript - 剑道网格内联组合框不改变值
- .htaccess - .htaccess 删除尾部斜杠
- tomcat - 在 Tomcat 的 servlet 上编码俄语和中文文本的问题