惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Vercel News
Vercel News
The GitHub Blog
The GitHub Blog
博客园 - 【当耐特】
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Recent Announcements
Recent Announcements
D
Docker
GbyAI
GbyAI
酷 壳 – CoolShell
酷 壳 – CoolShell
WordPress大学
WordPress大学
The Cloudflare Blog
雷峰网
雷峰网
A
About on SuperTechFans
小众软件
小众软件
博客园 - Franky
博客园 - 聂微东
F
Full Disclosure
大猫的无限游戏
大猫的无限游戏
C
Check Point Blog
MongoDB | Blog
MongoDB | Blog
G
Google Developers Blog
Microsoft Azure Blog
Microsoft Azure Blog
U
Unit 42
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
V2EX
Engineering at Meta
Engineering at Meta
宝玉的分享
宝玉的分享
aimingoo的专栏
aimingoo的专栏
量子位
P
Proofpoint News Feed
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
罗磊的独立博客
Martin Fowler
Martin Fowler
D
DataBreaches.Net
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
S
Secure Thoughts
Project Zero
Project Zero
L
LangChain Blog
阮一峰的网络日志
阮一峰的网络日志
C
Cybersecurity and Infrastructure Security Agency CISA
T
Tailwind CSS Blog
S
Schneier on Security
Blog — PlanetScale
Blog — PlanetScale
The Hacker News
The Hacker News
Spread Privacy
Spread Privacy
Security Latest
Security Latest
NISL@THU
NISL@THU
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
C
CXSECURITY Database RSS Feed - CXSecurity.com
J
Java Code Geeks

博客园 - 神游虚空

解决 GDAL 用 C# 访问时,中文乱码问题。 学习AI编程 安装 RAGFlow 安装 KTransformer 量化投资赚的哪方面的钱? python中调用 .net 的 dll 时,报错:Exception has occurred: TypeLoadException 使用 Open XML SDK 实现 html 富文本转换为 docx 格式示例 在python中 先调用C#的dll 返回了一个类的列表,如何把这个列表转换为 python 中的 DataFrame? vue项目服务器部属源码调试解决办法 vue3 + ts + element_plus 创建后台管理系统,学习记录 大A指数周内效应分析 两个通达信公式 如何在.netcore 上实现 Rbac 权限管理 修道是精神上的减熵过程 BPMN2.0 Specifaction 节选翻译,10.4.6 事件处理(handling Events,原文 275页) BPMN2.0 Specifaction 节选翻译,10.4 事件 Events (原文233页) 使用ef或dbcontext的时候主要注意三个问题 BPMN2.0 Specifaction 节选翻译,10.2.8 循环特征 Loop Characteristics (原文 189页) BPMN2.0 Specifaction 节选翻译,10.2.5 子流程 Sub-Processes (原文173页) BPMN2.0 Specifaction 节选翻译,10 Process (原文145页)
EFCore 中 group 分组后,只选出每组中含有最大值的数据行
神游虚空 · 2021-01-28 · via 博客园 - 神游虚空

一、背景

最近在 工作流项目 里使用 EFCore 遇到需要 group 分组后,只选出每组中含有最大值的数据行。

二、解决方案

先分组用 group 找到分组中的最大值,再用  join  查出对应的行。

var groupFlows = Context.Set<TInstanceFlow>().AsNoTracking()
            .GroupBy(f => f.ProcessInstanceId)
            .Select(g => new { instanceId = g.Key, finish = g.Max(f => f.Finish) });

var flows = Context.Set<TInstanceFlow>().AsNoTracking()
          .Join(groupFlows,
            o => new { f1 = o.ProcessInstanceId, f2 = o.Finish },
            i => new { f1 = i.instanceId, f2 = i.finish },
            (o, i) => new { o, i })
          .Select(g => new
          {
            Id = g.o.Id,
            ProcessInstanceId = g.i.instanceId,
            IsCanUndo = g.o.IsCanUndo,
          });

关键点是红色部分的键值对匹配。

三、参考资料

select-rows-with-maximum-value-on-a-column-in-sql-server

 join-query-in-ef-core/