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

推荐订阅源

L
LangChain Blog
博客园 - 司徒正美
美团技术团队
WordPress大学
WordPress大学
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
人人都是产品经理
人人都是产品经理
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Troy Hunt's Blog
S
Schneier on Security
T
The Exploit Database - CXSecurity.com
P
Proofpoint News Feed
云风的 BLOG
云风的 BLOG
Engineering at Meta
Engineering at Meta
Cisco Talos Blog
Cisco Talos Blog
T
Tor Project blog
B
Blog
NISL@THU
NISL@THU
月光博客
月光博客
博客园 - 【当耐特】
AWS News Blog
AWS News Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
腾讯CDC
L
Lohrmann on Cybersecurity
The Cloudflare Blog
L
LINUX DO - 最新话题
S
Security @ Cisco Blogs
S
Secure Thoughts
Spread Privacy
Spread Privacy
有赞技术团队
有赞技术团队
The Last Watchdog
The Last Watchdog
Project Zero
Project Zero
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Vercel News
Vercel News
H
Hacker News: Front Page
S
SegmentFault 最新的问题
Schneier on Security
Schneier on Security
aimingoo的专栏
aimingoo的专栏
P
Privacy & Cybersecurity Law Blog
博客园 - 三生石上(FineUI控件)
Forbes - Security
Forbes - Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
I
InfoQ
T
Tailwind CSS Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
G
GRAHAM CLULEY
W
WeLiveSecurity
小众软件
小众软件
Recorded Future
Recorded Future
Cyberwarzone
Cyberwarzone
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org

博客园 - 破甲

转:Chrome调试工具介绍 转:一组jQuery插件的连接 动态的链式传递执行 关于导出属性 Aop中动态横切与静态横切 老张的灵魂——敏捷回顾 LINQ to SQL(LINQ2SQL) vs. ADO.NET Entity Framework(ADOEF)-ccBoy版 ---阅读笔记 linq to sql 与linq to entities的选择 linq to sql 算ORM吗? 匿名方法实现(转) Oracle的并发多版本 读一致性 共享锁 排他锁 LING与HQL(三) LINQ与HQL (二) LINQ 与 HQL (一) C# 3.0的新特性(一) 挖掘ADO.NET Entity框架的性能 castle ar 的update方法!! HQL查询中的几个函数
System.Linq扩张方法Where (Lambda表达式)
破甲 · 2008-03-27 · via 博客园 - 破甲

简单的 Where,实现可能如下:
public static List<T> Where (this List<T> list,委托 delegate)
{
     List<T>  tmpList = new List<T> ();
     foreach( T p in list){
        if(delegate(p)){   
          tmpList.add(p);
         }
    }
     return tmpList;
 }

List<Person> persons = new List<Person> {"sds","sdsd"};

下面分别使用

Lambda表达式和匿名方法
List<Person>  tmp = persons.Where(p=>p.Name =="sds");
等于List<Person>  tmp = persons.Where((Person p)=>p.Name =="sds"); //编译器
还等于List<Person>  tmp = persons.Where(Delegate(Person p) {
                                                                       return p.Name =="sds";
                                                                   })不过linq to object采用的是延迟查询;在看下面一例:

  static void Main(string[] args)
  {
    var ints = new int[] { 1, 2, 3, 4, 5, 6 };
    IEnumerable<int>  q = from i in ints select i;

   foreach(............)
  }
  此时的q并未返回查询的结果,而是返回一个IEnumerable<int>,以使foreach可以工作;

这里有准确的说法:

http://blog.joycode.com/scottgu/archive/2007/04/09/100744.aspx