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

推荐订阅源

The Last Watchdog
The Last Watchdog
S
Securelist
T
Threat Research - Cisco Blogs
Forbes - Security
Forbes - Security
AI
AI
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Attack and Defense Labs
Attack and Defense Labs
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Know Your Adversary
Know Your Adversary
P
Privacy International News Feed
W
WeLiveSecurity
P
Palo Alto Networks Blog
O
OpenAI News
V2EX - 技术
V2EX - 技术
H
Heimdal Security Blog
L
Lohrmann on Cybersecurity
NISL@THU
NISL@THU
T
Tor Project blog
T
Threatpost
G
GRAHAM CLULEY
T
The Exploit Database - CXSecurity.com
云风的 BLOG
云风的 BLOG
人人都是产品经理
人人都是产品经理
A
Arctic Wolf
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Latest news
Latest news
Application and Cybersecurity Blog
Application and Cybersecurity Blog
T
Tenable Blog
量子位
L
LINUX DO - 最新话题
Webroot Blog
Webroot Blog
F
Fortinet All Blogs
C
CERT Recently Published Vulnerability Notes
Hacker News: Ask HN
Hacker News: Ask HN
U
Unit 42
T
Tailwind CSS Blog
WordPress大学
WordPress大学
N
News | PayPal Newsroom
C
CXSECURITY Database RSS Feed - CXSecurity.com
N
Netflix TechBlog - Medium
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Stack Overflow Blog
Stack Overflow Blog
Cloudbric
Cloudbric
C
Check Point Blog
V
Visual Studio Blog
The GitHub Blog
The GitHub Blog
The Hacker News
The Hacker News
B
Blog

博客园 - 里沃特

XR806开发板环境搭建记录 谈谈把网站迁移到阿里云的一些感想和其中遇到的一些问题 HTML5+JS 《五子飞》游戏实现(八)人机对战 HTML5+JS 《五子飞》游戏实现(七)游戏试玩 HTML5+JS 《五子飞》游戏实现(六)鼠标响应与多重选择 HTML5+JS 《五子飞》游戏实现(五)移动棋子 HTML5+JS 《五子飞》游戏实现(四)夹一个和挑一对 HTML5+JS 《五子飞》游戏实现(三)页面和棋盘棋子 HTML5+JS 《五子飞》游戏实现(二)路线分析和资源准备 HTML5+JS 《五子飞》游戏实现(一)规则 cocos2dx-2.2.1 免 Cygwin 环境搭建(Win8+VS2013+ADT Bundle+android-ndk-r9c) 深入理解 cocos2d-x 坐标系 在VS2010 下编译 cocos2d-x-2.1.4 FFmpeg 1.2 for Android 生成一个动态库 FFmpeg 1.2 for Android 编译动态库 C# 统一对 try...catch 的调用,方便保存错误日志。 手机:由全触摸屏失效所想到的 愚人节奉献给大家的礼物,敬请收下 C# 让控件全屏显示(WinForm)
Linq 批量更新数据
里沃特 · 2012-11-28 · via 博客园 - 里沃特

最近一直在用 Linq,Linq确定很方便,提供了一大堆的函数,可是就是没有发现 Update 函数,杯具了。

说之前先看一个博友的文章:http://www.cnblogs.com/manupstairs/archive/2012/11/27/2790114.html

我忘记了他一直在说 SelectMany ,于是问他怎么更新数据。

比如我们考试会遇到这样的情况,凡是60分以下的同学,都再原来的分数基础上加1,照顾一下59分的同学

博主回答我的是:teachers.SelectMany(t => t.Students).ToList().ForEach(s => s.Score = s.Score + 1);

这个确实是一种解决方法,但经过 ToList 一次后,会不会对性能有所影响?我想应该会。

后来自己慢慢摸索,发现有一种变通的方法可以解决此问题:

teachers.SelectMany(t => t.Students).Where(s=>s.Score<60).Any(s=>(s.Score+=1)>0);

原来一切都很简单!