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

推荐订阅源

F
Fortinet All Blogs
Attack and Defense Labs
Attack and Defense Labs
V2EX - 技术
V2EX - 技术
O
OpenAI News
S
Secure Thoughts
H
Heimdal Security Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Schneier on Security
Schneier on Security
H
Hacker News: Front Page
S
Security Affairs
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
The Register - Security
The Register - Security
GbyAI
GbyAI
Cloudbric
Cloudbric
MongoDB | Blog
MongoDB | Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
K
Kaspersky official blog
Forbes - Security
Forbes - Security
Y
Y Combinator Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
Scott Helme
Scott Helme
Hacker News - Newest:
Hacker News - Newest: "LLM"
The Cloudflare Blog
Recorded Future
Recorded Future
人人都是产品经理
人人都是产品经理
Cyberwarzone
Cyberwarzone
C
CERT Recently Published Vulnerability Notes
Webroot Blog
Webroot Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
L
LangChain Blog
T
Tor Project blog
Microsoft Azure Blog
Microsoft Azure Blog
博客园_首页
Hacker News: Ask HN
Hacker News: Ask HN
Blog — PlanetScale
Blog — PlanetScale
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
B
Blog RSS Feed
N
News and Events Feed by Topic
阮一峰的网络日志
阮一峰的网络日志
I
Intezer
V
V2EX
T
Tailwind CSS Blog
SecWiki News
SecWiki News
NISL@THU
NISL@THU
C
Check Point Blog

博客园 - 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