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

推荐订阅源

V
Vulnerabilities – Threatpost
V
Visual Studio Blog
博客园_首页
Last Week in AI
Last Week in AI
J
Java Code Geeks
V
V2EX
博客园 - Franky
Apple Machine Learning Research
Apple Machine Learning Research
云风的 BLOG
云风的 BLOG
博客园 - 司徒正美
N
Netflix TechBlog - Medium
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
爱范儿
爱范儿
B
Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
U
Unit 42
W
WeLiveSecurity
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
A
Arctic Wolf
S
Security Affairs
博客园 - 聂微东
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Microsoft Azure Blog
Microsoft Azure Blog
雷峰网
雷峰网
L
LangChain Blog
大猫的无限游戏
大猫的无限游戏
罗磊的独立博客
I
Intezer
有赞技术团队
有赞技术团队
Forbes - Security
Forbes - Security
Engineering at Meta
Engineering at Meta
D
Docker
C
Check Point Blog
N
News | PayPal Newsroom
H
Hacker News: Front Page
T
The Blog of Author Tim Ferriss
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
C
CXSECURITY Database RSS Feed - CXSecurity.com
SecWiki News
SecWiki News
The Last Watchdog
The Last Watchdog
Recorded Future
Recorded Future
量子位
NISL@THU
NISL@THU
T
Tailwind CSS Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
MongoDB | Blog
MongoDB | Blog
MyScale Blog
MyScale Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
I
InfoQ
Hacker News: Ask HN
Hacker News: Ask HN

博客园 - 每天进步多一点

MySQL5.7实现row_number()和over()函数 C#学习相关系列之Linq用法---group和join相关用法 常用知识-T-SQL优化 mysql窗口函数、Mysql分析函数 MySQL系列三(定位慢SQL、索引优化、SQL优化)Using filesort MySQL 内存相关参数设置 MySQL COALESCE 函数使用详解 SQL性能优化指南:如何优化MySQL多表join场景 MySQL内部临时表(Using temporary)案例详解及优化解决方法 cookie操作类(加密,获取,删除) MySql 5.7 索引不存在则创建,存在则忽略 SQL SERVER年月周日超止时间 数据抽取的常见理论方法 ETL系列-数据抽取(Extract) 常用时间sql语句 数据库运维:mysql 数据库迁移方法-mysqldump 了解MySQL中的JSON_ARRAYAGG和JSON_OBJECT函数 MySQL的IFNULL()、ISNULL()、NULLIF()函数用法说明 如何看懂explain工具信息,使用explain工具来分析索引 mysql 如何查看sql语句执行时间和效率
linq group by having 实现
每天进步多一点 · 2026-03-27 · via 博客园 - 每天进步多一点
System.Diagnostics.Stopwatch st1 = new System.Diagnostics.Stopwatch();
st1.Start();
XDocument xdom = XDocument.Load(XmlPath);
var restElements = xdom.Descendants("rest").ToList();
st1.Stop();
HttpContext.Current.Response.Write("1.载入XML时间" + st1.ElapsedMilliseconds + "<br>");

载入一个大一点的文件,我这里显示花时间 1700毫秒 左右

System.Diagnostics.Stopwatch st = new System.Diagnostics.Stopwatch();
st.Start();
var Hotels = (from hotels in restElements
              where  hotels.Element("lat") != null &&  
              hotels.Element("lat").Value != string.Empty 
              select new
              {
                  State = hotels.Element("state").Value,
                  StateCityKey = (hotels.Element("state").Value + "-" + hotels.Element("city").Value).ToUpper()
              }).ToList();

过滤,生成匿名对象,然后Tolist();这一步的没什么好说的,关键是不要让他监视XML文件,不要让他延时加载,生成一个KEY

var hotelsGroup =
    (from hotel in Hotels
     group hotel by hotel.StateCityKey
         into h
         select new
         {
             StateCityKey = h.Key,
             count = h.Count(),
             hgrou = h
         } into c
         where c.count > 2
         select c).ToList();
st.Stop();
HttpContext.Current.Response.Write("2.分组耗费" + st.ElapsedMilliseconds);
long a = st1.ElapsedMilliseconds + st.ElapsedMilliseconds;
HttpContext.Current.Response.Write("<br>1+2总耗费 :" + a + "毫秒<br>");

通过KEY(StateCityKey)进行分组,注意COUNT,where c.count > 2 对分组以后的数据进行判断,相当于HAVING用的不是COUNT() 是count