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

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
G
Google Developers Blog
Spread Privacy
Spread Privacy
I
InfoQ
V
V2EX
S
Schneier on Security
小众软件
小众软件
C
CERT Recently Published Vulnerability Notes
博客园 - 聂微东
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Stack Overflow Blog
Stack Overflow Blog
T
Threat Research - Cisco Blogs
L
Lohrmann on Cybersecurity
Recent Announcements
Recent Announcements
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Attack and Defense Labs
Attack and Defense Labs
云风的 BLOG
云风的 BLOG
The Hacker News
The Hacker News
S
SegmentFault 最新的问题
C
Cybersecurity and Infrastructure Security Agency CISA
NISL@THU
NISL@THU
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
GbyAI
GbyAI
Latest news
Latest news
S
Secure Thoughts
Project Zero
Project Zero
MongoDB | Blog
MongoDB | Blog
I
Intezer
Security Latest
Security Latest
Apple Machine Learning Research
Apple Machine Learning Research
Vercel News
Vercel News
N
Netflix TechBlog - Medium
V2EX - 技术
V2EX - 技术
量子位
T
Threatpost
T
The Blog of Author Tim Ferriss
Y
Y Combinator Blog
T
Tor Project blog
A
Arctic Wolf
Microsoft Security Blog
Microsoft Security Blog
T
The Exploit Database - CXSecurity.com
大猫的无限游戏
大猫的无限游戏
T
Tailwind CSS Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
C
Check Point Blog
博客园 - Franky
Google DeepMind News
Google DeepMind News
The Register - Security
The Register - Security
The GitHub Blog
The GitHub Blog
L
LINUX DO - 热门话题

博客园 - ProjectDD

NET 中 Async/Await 的演进:从状态机到运行时优化的 Continuation C# 指针用法小结 C# BinaryPrimitives 类 C# 内存对齐 关于C# await的一点新理解 关于排序算法 C# Dev Kit 经常导致崩溃 不太会用Span<T> 看文档上的优点估摸着试试 span,memory,ArrayPool,MemoryPool,等的性能对比 C# simd 性能雷点记录 C# 模式匹配里应该注意的几点 高中生理解梯度为何是方向导数极大值 概略 deep net 通过relu 进行函数逼近 win10 下安装 rust 的 依赖配置,通过vs2022 C# 有多需要aot 24个希腊字母的中文拼音版 英语发音探讨 sagemath 9.x 下的 jupyter 工作路径设置 Serializing delegates is not supported on this platform
linq 查询关于 from子句
ProjectDD · 2024-02-02 · via 博客园 - ProjectDD

这玩意儿不是强制的,已经测试了解,

var x = from i in source ... 

这是linq中标准的from子句的写法,它默认会定义两个变量位置一个 是上式所示的i 另一个是source,一般来说按要求 source需要是可枚举的即它能够被foreach,一般所有集合类型都是可枚举的,但是就算source是一个一般的类不是集合,from 子句这么写也不会报错,最后后面传递过去的是一个object对象而已还是可用的不影响。

linq 表达式中的关键字所代表就是一种扩展方法调用的另一种写法,如果一个Linq 表达式里有多个上下文关键字比如where/select/group by/orderby/join 等那么就代表这些扩展方法是链式调用的。也就是说linq表达式这种写法完全等于同扩展方法调用而Linq 表达式按官方规定需要由from子句开头,由select / group语句结束,其实就是一串特定的扩展方法,需要注意这些扩展方法除了命名与必要的参数有要求外,对于其内容是没有要求的

具体请看:

public interface IX11 {

}
public class X11 : IX11 {
  public X11() {
    Console.WriteLine("X11");
  }
}
static public class X11Ex {
  static public IX11 Where(this IX11 q, Expression<Func<object, bool>> condition) {
    Console.WriteLine("X11Ex.Where");
    return q;
  }
  //select
  static public IX11 Select(this IX11 q, Expression<Func<object, object>> selector) {
    Console.WriteLine("X11Ex.Select");
    return q;
  }
}
  [TestMethod]
  public void m18(){
    var x11=new X11();
    var x=from i in x11 where i.Equals(3) select i;
    Console.WriteLine(x);
  }

已通过 m18 [5 ms]
标准输出消息:
X11
X11Ex.Where
test2024.scenes.X11